TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rui Ruivo
NA
132
37.2k
Threading - t.Join() - What does it do exactly?
Apr 12 2018 4:11 PM
Hello
I am deepening my understanding of the c# language and trying to really understand all the little details.
I have the following code in wish i cannot understand the difference in using t.Join() .
Can anyone help me ?
using
System;
using
System.Threading;
namespace
_70483
{
public
static
class
Program
{
public
static
void
ThreadMethod()
{
for
(
int
i = 0; i<10; i++)
{
Console.WriteLine(
"ThreadProc: {0}"
, i);
Thread.Sleep(0);
}
}
static
void
Main(string[] args)
{
Thread t =
new
Thread(
new
ThreadStart (ThreadMethod));
t.Start();
for
(
int
i = 0; i< 4 ; i++)
{
Console.WriteLine(
"Main thread: Do some work."
);
Thread.Sleep(0);
}
t.Join();
// Method is called on the main thread to let it wait until the other thread fnishes.
Console.ReadLine();
}
}
}
I have tryed to remove it and cannot see any difference.
Is it maybe because i have Thread.Sleep(0) ?
Best regards
Rui
Reply
Answers (
2
)
CKEditor to ASP.net
Get Value from list of objects