File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes thread lock Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "thread lock" Watch "thread lock" New topic
Author

thread lock

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3829
join() method doesn't return lock .

synchronized public void m() {
// some code
t.start();
t.join(); // line2
// spme code
}

Suppose the thread which is executing m method has lock , In line 2 we are joining this thread to t , so it will wait untill t will do its work , at the time of waiting also it has lock ... right ??

thanks a lot .
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16811
    
  19

join() will wait until the run() method of the t thread finishes. And it does not give up it's lock while waiting.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: thread lock
 
Similar Threads
thread will aquire lock of which object ...
Creating multiple children threads
Doubt with a thread question about "synchronized(sa)"
synchronized
Parent Thread gets the same object lock has child threads? Confused!!