dcsimg
question about synchronisation
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   anirudh_kumar
Posted On:   Wednesday, April 21, 2004 12:38 AM

Two synchronised methods s1 & s2 are there on a object.Thread t1 want to execute s1 and thread t2 want to execute s2.Which method will be executed first and why?? are they run parralel ??

Re: question about synchronisation

Posted By:   Rakesh_Ranjan  
Posted On:   Thursday, May 6, 2004 12:50 AM


Synchronization enables object label lock. When a thread of an Object calls synchronized method, other threads of same object cannot call the remaining synchronized methods. But it can call other unsynchronized methods. So they can not run parallel. Which method will execute first it will depend on which thread get first chance to execute it synchronized method. It again depends on state of thread, Context Switching etc.
Thanks and Regards
Rakesh Ranjan

Re: question about synchronisation

Posted By:   Simon_Ablett  
Posted On:   Wednesday, April 21, 2004 03:14 AM

It depends upon who gets the mutex lock on the object first.

Regards.
About | Sitemap | Contact