Forums Register Login

Locks in synchronization

+Pie Number of slices to send: Send


I do not understand how the lock is being acquired .
+Pie Number of slices to send: Send
The lock is being acquired when either thread enters the synchronized block ???

The confusing thing about this code is that it requires knowledge of java string's and how they are intern'ed , this kind of thing should never appear in real code, you'd be more likely to find it in a java quiz or the like i.e. don't use "a" or any other string literal as your lock.
I like tacos! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 544 times.
Similar Threads
After notify()
tthread doubt
Question about wait() and notify()
Beginner: Threads vs. Runnables
wait() releases all locks?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:21:18.