This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread priorities and Daemon threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread priorities and Daemon threads" Watch "Thread priorities and Daemon threads" New topic
Author

Thread priorities and Daemon threads

Divya Eknath
Greenhorn

Joined: Jul 27, 2006
Posts: 9
I ran the program below and got option(C) as the output but is this the only possible output?Are the thread priorities guaranteed to be considered?


What are the possible outputs of above program?
Options:
a) A Done
b) B Done
c) A Done B Done
d) B Done A Done
e) java doesnt support this type....
[ July 29, 2006: Message edited by: Barry Gaunt ]
Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
thread priorities are not guaranteed different Jvm 's have different thread priorities so dont not rely on thread priorities.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

When you use the max and min priorities the chaces that "a" will execute first are more. However the JVM may decide to interrupt your "a" thread thus making "b" to print out first.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Please surround formatted code with tags - many people will not bother to read it otherwise. I will edit your original topic this time.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread priorities and Daemon threads
 
Similar Threads
Thread - Confirmation
Using wait/notify()
Concept of locks and synchronization !
Insights into synchronization
Problem On using wait() in THreads