This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes another help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "another help" Watch "another help" New topic

another help

wang jie

Joined: May 01, 2002
Posts: 8
will the setPriority and exits synchronized code directly cause a thread to stop executing?
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Unfortunately, I haven't been able to find any documentation to back this up, but I believe that neither case will cause a thread to stop executing.

SCJP Tipline, etc.
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
It makes no sense for exiting a synchronized region to force a thread to stop executing. All a synchronized region says is "at the moment I need exclusive access to the object". The thread still has work to do when it isn't in a sync region, so there is no reason to force it to stop executing.
There really aren't any solid guarantees made about what priority even means, so there is no reason why changing it would force a thread to stop executing.

Reid - SCJP2 (April 2002)
It is sorta covered in the JavaRanch Style Guide.
subject: another help
Similar Threads
Puzzling question from Mughal and Rasmussen
Static Initializers.
Interesting classpath question
A Poll, a Poll, a very simple Poll!