aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads -- start order Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "threads -- start order" Watch "threads -- start order" New topic
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
    
  19

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
    
  19

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 ??
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: threads -- start order
 
Similar Threads
"synchronizing" a static member
tell me the difference.thanks.
Deadlocks in Threads?
how to use join( )
wait() and notifyAll()