wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Synchronize the create method? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Synchronize the create method?" Watch "Synchronize the create method?" New topic
Author

Synchronize the create method?

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Hi,
Just wondering did anyone end up having to synchronize upon the create method? Found mine became quite complex using 2 caches and when running the multi-threaded tests, some threads overwrote each other. Would appreciate people's views.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5398
    
  13

Hi Mark,

I synchronized all methods, so also the create-method.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Nicolas Kal
Ranch Hand

Joined: Sep 09, 2009
Posts: 69
Mark,

I have placed synchronisation blocks in the class that provides a means of communication between client and server(backend in the case of standalone). The blocks are synchronized on the Data singleton class lock.

Regards,
Nicolas


SCJP 6.0 , SBCD (Preparing..),
MSc Enterprise Systems Development, BSc Computer Science
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2266
    
    3

Nicolas Kal wrote:The blocks are synchronized on the Data singleton class lock.


Since the Data class implements the Singleton pattern, this approach can do the job as well.

I too synchronized all methods of the Data class.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Matheus Mendes
Ranch Hand

Joined: May 15, 2007
Posts: 66
I did the same thing, synchronize all methods = )


The Death of one is a tragedy, but the Death of a million is just a statistic. Joseph Stalin

SCJP 6.0, SCJD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Synchronize the create method?