| 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: 4351
|
|
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: 2212
|
|
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: 65
|
|
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
|
 |
 |
|
|
subject: Synchronize the create method?
|
|
|