aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Allowing join method when testing multi-threaded access to 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 "Allowing join method when testing multi-threaded access to create method?" Watch "Allowing join method when testing multi-threaded access to create method?" New topic
Author

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

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
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

Joined: Aug 17, 2009
Posts: 160
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
Bartender

Joined: Jul 19, 2004
Posts: 5545
    
  13

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


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Allowing join method when testing multi-threaded access to create method?