About Question enthuware.ocpjp.v7.2.1536 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
sinapse
Posts: 27
Joined: Sat Aug 31, 2013 5:38 pm
Contact:

About Question enthuware.ocpjp.v7.2.1536 :

Post by sinapse »

Hi,
why synchronized (this)
is not a good option here ?

Thanks

admin
Site Admin
Posts: 10405
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post 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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 10 guests