This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Testing and the fly likes Test case with multithreads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Test case with multithreads" Watch "Test case with multithreads" New topic

Test case with multithreads

Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Hi guys,
If a junit test case spawns new threads,
must all the threads terminate before the next test case is called?
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I believe this depends on whether these threads are "daemon" or "regular" threads.

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Andy Hunt
Ranch Hand

Joined: May 01, 2001
Posts: 55
My memory on this is a little fuzzy, but as I recall JUnit as shipped has (or had) some bugs with regard to handling multiple threads.
There was a patch available from a 3rd party (just a Google away :-) that dealt with threads in a much more robust manner. In the patched version, I believe the answer to your question is "yes."

/\ndy Hunt<br /> <a href="" target="_blank" rel="nofollow"></a>
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Thank you Lasse and Andy.
I agree. Here's the link:
subject: Test case with multithreads
It's not a secret anymore!