what is the use of syncronize , if we preempts any current thread(which is executing a synchronize method) with the new high priority thread?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Murali_Reddy
Posted On:   Monday, October 31, 2005 12:18 AM

Thread T1 already executing the sync code by holding a lock on a perticular obj. and updated the shared values. Now this thread preempted, and the lock handovered to another thread T2 to execute the same sync method., it resets all the shared values with new values. it finished its execution and deads. now T1 wants to continue to execute from where it stoped.CAN T1 GET ITS ORIGINAL VALUES WHAT IT SUPPOSING?,if NOT wHAT IS THE USE OF SYNC. ?

Re: what is the use of syncronize , if we preempts any current thread(which is executing a synchronize method) with the new high priority thread?

Posted By:   Edward_Harned  
Posted On:   Monday, October 31, 2005 10:02 AM

If thread T1 gets preempted, it does not loose its lock on the synchronized object. Thread T2 will wait until thread T1 regains control and releases the lock.

About | Sitemap | Contact