Page 1 of 1

About Question enthuware.ocpjp.v7.2.1536 :

Posted: Mon Sep 09, 2013 3:38 am
by sinapse
Hi,
why synchronized (this)
is not a good option here ?

Thanks

Re: About Question enthuware.ocpjp.v7.2.1536 :

Posted: Mon Sep 09, 2013 5:40 pm
by admin
Synchronizing on "this" will synchronize on the Producer instance and Consumer instance, not on the data instance. So producer thread and consumer threads will be able to access data simultaneously, which you do not want.

HTH,
Paul.