OCPJP 6.0 93%
OCPJWCD 5.0 98%
mohitkumar gupta wrote:
both threads have there separate locks
Under synchronization block,we acquire lock on object reference not on thread.
OCPJP 6.0 93%
OCPJWCD 5.0 98%
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
mohitkumar gupta wrote:
Thread t1 has lock on ns
and Thread t2 has lock on ns2
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
mohitkumar gupta wrote:
Thread t1 has lock on ns
and Thread t2 has lock on ns2
OCPJP 6.0 93%
OCPJWCD 5.0 98%
mohitkumar gupta wrote:
Thread t1 has lock on ns
and Thread t2 has lock on ns2
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Arjun Srivastava:
i don't know if you have read the book carefully or not.
Thread always hold the lock on the object,every object has built in lock that comes in action when the object has synchronized method code or block.
OCPJP 6.0 93%
OCPJWCD 5.0 98%
mohitkumar gupta wrote:
Sorry, i had put the wrong code
Thread t1 would have lock on ns
Thread t2 would have lock on ns1
Now, IS the output:
X X X2 X2
possible now ?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
mohitkumar gupta wrote:
acquire lock on XSync object when,it see's synchronize(this).then,
Am,i right now ?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
mohitkumar gupta wrote:
so,Thread t1 or t2 whosoever runs first would automatically acquire lock on XSync object when,it see's synchronize(this).then,that thread would not release lock until the code in synchronized block or function is complete
Am,i right now ?
Abimaran :
acquire lock on XSync object when,it see's synchronize(this).then,
Am,i right now ?
OCPJP 6.0 93%
OCPJWCD 5.0 98%
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP 6.0 93%
OCPJWCD 5.0 98%
Don't get me started about those stupid light bulbs. |