If I create a thread which runs SomeMethod
below, and then create 5 more threads which try to run SomeMethod
below before thread #1 is finished, am I guaranteed that the threads will run in the order they were created?
That is, after the first thread finishes with SomeMethod
, is it random chance who the next thread will be who gets to run SomeMethod
? Or am I guaranteed that it will be the "next in line" thread, that is, the 2nd thread I created, followed by the 3rd, 4th, 5th, and 6th thread.
private static object lockObject = new Object();
public static SomeMethod()
//do your stuff