Hi Ranchers. These are just some snippets from a couple of JQ+ thread Qs. Q1) When a thread calls notify() from within its synchronized block, does it say to the waiting threads that "Hey! Guys, I am relinquishing the lock on this object." & actually does so ? Q2) Can a join operation on a thread cause some other thread to stop? Thanks - Himanshu
A1) No. Unlike wait(), which blocks immediately and gives up its lock, notify() and notifyAll() won't actually give up the lock on the object until execution exits the synchronized block in which the notify()/notifyAll() is located. Example: ... synchronized(this){ //do stuff notify(); //thread not block, nor locks surrendered //do more stuff } //end of synchronized block, thread gives up locks
A2) Yes. Calling join() on thread A causes the current thread to be suspended until thread A completes, at which time the thread that invoked join() will continue.
there are other version of the join(), which waits for milli seconds, for a thread to complete, then starts whether or not calling thread has got its execution complete or not.
an student of Operation Badar ( a educational movement in Pakistan).
If a regular clown is funny, then a larger clown would be funnier. Math. Verified by this tiny ad:
a bit of art, as a gift, the permaculture playing cards