Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread priorities and Daemon threads

 
Divya Eknath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thread priorities are not guaranteed different Jvm 's have different thread priorities so dont not rely on thread priorities.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please surround formatted code with tags - many people will not bother to read it otherwise. I will edit your original topic this time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic