• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Synchronize the create method?

 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9795
101
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

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

Kind regards,
Roel
 
Nicolas Kal
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matheus Mendes
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did the same thing, synchronize all methods = )

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic