| Author |
threads -- start order
|
H. Ali
Greenhorn
Joined: Feb 25, 2011
Posts: 21
|
|
is it possible that t2 starts before t1 even thought we have :
t1.start();
t2.start();
does it have to be in the same order???
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16681
|
|
This thread was split from this topic...
http://www.coderanch.com/t/463326/java-programmer-SCJP/certification/Concurrency-Thread-sleep
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16681
|
|
Jose Armando wrote:is it possible that t2 starts before t1 even thought we have :
t1.start();
t2.start();
does it have to be in the same order???
The Java specification doesn't impose any order. It is dependent on the underlying operating system's threading mechanism.
Having said that, how do you define "start order"? Even if the specification impose an order, how can you tell? It is completely possible for t1 to "start" first, and t2 to "start" second"... but t1 gets scheduled on a processor that immediate takes a hardware interrupt.
Henry
|
 |
H. Ali
Greenhorn
Joined: Feb 25, 2011
Posts: 21
|
|
Henry
i was actually asking about the question in this topic:
http://www.coderanch.com/t/463326/java-programmer-...ation/Concurrency-Thread-sleep
is it possible that
printValue is printed then printName ??
|
 |
 |
|
|
subject: threads -- start order
|
|
|