| Author |
Thread synchronisation - Using a string literal for locking
|
O. Ziggy
Ranch Hand
Joined: Oct 02, 2005
Posts: 430
|
|
The above test produces the following output
I don't understand why the last three thread are not using the String object as a shared lock like the first three threads. Even though they last three threads are using a different instance of 'RunnableThread', shouldnt they be synchronised because there is only once copy for 'str' in the string constant pool?
Thanks
|
 |
O. Ziggy
Ranch Hand
Joined: Oct 02, 2005
Posts: 430
|
|
Ill answer my own question:
The code is not actually synchronising on the str object..
|
 |
 |
|
|
subject: Thread synchronisation - Using a string literal for locking
|
|
|