Let me know if you need to see the exercise 9.2 question.
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankur kothari wrote:hey i would like to ask the difference between synchronized(s) and synchronized(this);
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankur kothari wrote:i get the output of AAA...BBB...CCC.... when i use synchronize(s) but the output is different when i use "this"......what exactly happens when i used "this"....i thought the output should be the same
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankur kothari wrote:but whenever a new thread is started isnt the value of s going to be A since everytime a new thread is created the Stringbuffer is initialised to A......
please explain....
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankur kothari wrote:but whenever a new thread is started isnt the value of s going to be A since everytime a new thread is created the Stringbuffer is initialised to A......
please explain....
Ankur kothari wrote:Thanks vijita and Vevang.....understood everything...i replaced StringBuffer with String and output comes is all A.....
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Ankur kothari wrote:but what i don't understand is using synchronized(s)....isnt the value of s "A" everytime a new thread starts......so why am i getting the output of A.......100timesB.......100timesC.....100times
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|