| 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: 4349
|
|
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/
|
 |
 |
|
|
subject: Allowing join method when testing multi-threaded access to create method?
|
|
|