“An Unstarted thread is transitioned into the Running state by calling Start.” [from msdn ThreadState enumeration docs.
Exactly when does a thread transition from Unstarted to Running?
If I instantiate a thread and call Start, is there a delay before the thread actually moves to Running? If the instantiating thread calls Join immediately after Start, is there a risk it’ll catch the new thread in an Unstarted state?
Its state becomes
Runningbefore theStart()method returns, though it may not yet (and quite often will not) have done any actual work, as it may not yet have been given any core time. Most of the time the fact that we can think of the tread as running is enough (just as most of the time we can think “we have 6 threads running” when if we only have 4 cores the obviously we’ve only got up to 4 actually doing something). It could also be that by the time you get to the next instruction on the calling thread, that it’sWaitSleepJoinor evenStoppedbut it won’t beUnstarted.It’s perfectly safe to call
Join()even in the very next statement afterStart()(though that would rarely be useful).