• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Allowing join method when testing multi-threaded access to create method?

 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm having difficulty in my application with allowing multiple threaded access in the create method. Is it possible to specify that if one is testing my create method in a multi-threaded environment, that the currentThread.join() within the threading code application must be invoked? Would this be allowed or not or could it be a failure issue? Thanks.
 
Mark O' Sullivan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Apologises have solved this issue. I wrote a multi-threaded application to test my create method, did the usual, created a private class to simulate a thread instance. But I also needed to test multiple instances of the application. But i created the instances of the application within the private thread class instead of top of the testing class. This lead to some unusual problems such as a create record being created 3 times with the same name. I'm new to multi-threading applications but I'll learn from this mistake, believe me. Thanks for help!
 
Roel De Nijs
Sheriff
Posts: 10451
137
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,

Glad you solved your issue. And to confirm: if you have to use things like currentThread.join() you are on the wrong track. The only things I needed to make my Data class thread-safe are synchronized, wait and notifyAll.

Kind regards,
Roel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic