When The Going Gets Tougher,The Tougher gets Going
Steve
When The Going Gets Tougher,The Tougher gets Going
Steve
Deepak Lal wrote:
how should my Public static main method look like.I'm unable to figure that part for Scenario 1 and Scenario 2
SCJP6.0,My blog Ranchers from Delhi
SCJP6.0,My blog Ranchers from Delhi
OCPJP 85%
When The Going Gets Tougher,The Tougher gets Going
When The Going Gets Tougher,The Tougher gets Going
Deepak Lal wrote:
How should we synchronize the read and write method for static variable integer i.?Example provided will be helpful.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
Deepak Lal wrote:
How should we synchronize the read and write method for static variable integer i.?Example provided will be helpful.
Synchronization is for objects! Not to primitives!
Steve
When The Going Gets Tougher,The Tougher gets Going
When The Going Gets Tougher,The Tougher gets Going
Steve
When The Going Gets Tougher,The Tougher gets Going
Steve Luke wrote:
Abimaran Kugathasan wrote:
Deepak Lal wrote:
How should we synchronize the read and write method for static variable integer i.?Example provided will be helpful.
Synchronization is for objects! Not to primitives!
That is incorrect! You must protect primitives with synchronization as well, you just can't gain a lock on the primitive itself so you need to lock on something else.
Abimaran, this situation appears special ....
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Deepak Lal wrote:@Ranchers, @Steve I'm back with another scenario.see below
How should i apply synchronization for Scenario 4 such that read and write method are executed by 2 different threads. (as demonstrated by Joe lemmer in one of the posts) ?Sample code provided will be appreciated.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
When The Going Gets Tougher,The Tougher gets Going
You have to lock on an Object which is available in the same contexts as the data you want to protect. For static content that generally means an Object stored in a static reference.
Steve
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
When The Going Gets Tougher,The Tougher gets Going
Steve
When The Going Gets Tougher,The Tougher gets Going
Steve
if you think brussel sprouts are yummy, you should try any other food. And this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
|