|
I want a thread in a Java program to loop until all other threads die, and then end the loop. How can I know when my loop thread is the only thread remaining?
In my situation, the loop thread will have no reference to any other threads, so I don't think...
Started by FarmBoy on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Set your loop thread to daemon mode
setDaemon(true.
Would this not be a situation where you would consider the Thread Pool Pattern ?
If not, would or might not help, depending on your use-case.
|
|
My strategy for threading issues in a Swing Java app is to divide methods in three types:
methods that should be accessed by the GUI thread. These methods should never block and may call swing methods. Not thread-safe. methods that should be accessed ...
Started by amarillion on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Dispatch Thread * <p> * Add this annotation to methods that perform potentially blocking operations be accessed by the * Event Dispatch Thread * <p> * Add this annotation to methods that call (swing that should be thread....
|
|
I'm setting up CI at present using Thoughtworks Studios' Cruise, Gallio to run xunit.net fact/tests, and ncover 2 to do code-coverage.
I noticed that running the code-coverage pegs one of the four CPUs that our build-agent server has, and wondered whether...
Started by Peter Mounce on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
I'd imagine it wouldn't be too much more work to have a thread pool to spawn tests/2008/05/09/ConcurrentUnitTestingWithXUnitNet....
In NUnit you can pass a /thread parameter which spawns test execution in a different thread.
Be difficult though.
|
Ask your Facebook Friends
|
I have a Java service which now will execute in a batch mode. Multi threaded support is added to the service so for every batch request a thread pool will be dedicated to execute the batch. The question is how do I test this? I have functional tests that...
Started by CodePolice on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
For example:
@Test....
By substituting the body of the threads with test code you should allows you to annotate your test methods and cause them to be executed in n threads concurrently.
Of the thread pool in isolation.
|
|
Hot-on-the-heels of of my previous unit testing related question, here's another toughie:
I have thus far avoided the nightmare that is testing multi-threaded code since it just seems like too much of a minefield. I'd like to ask how people have gone ...
Started by jkp on
, 17 posts
by 17 people.
Answer Snippets (Read the full thread at stackoverflow):
That has so far worked great for me, and I use the same approach for the thread pool of the concurrency pattern used:
Unit tests for classes that operate in a single thread and aren't thread aware -- easy,....
The test.
|
|
Executive Summary: When assertion errors are thrown in the threads, the unit test doesn't die. This makes sense, since one thread shouldn't be allowed to crash another thread. The question is how do I either 1) make the whole test fail when the first ...
Started by LES2 on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
If you are just trying just test this code....
To test that the code inside each thread is doing what it is supposed to test, may be you shouldHi, Concurrency is one of those things that are very difficult to unit test.
|
|
I've written a class and many unit test, but I did not make it thread safe. Now, I want to make the class thread safe, but to prove it and use TDD, I want to write some failing unit tests before I start refactoring.
Any good way to do this?
My first thought...
Started by TheSean on
, 8 posts
by 8 people.
Answer Snippets (Read the full thread at stackoverflow):
Using both tools is easy....
It won't find all of the race for deadlocks in your code (via unit test) and I think Chess checks for race conditions as well.
Condition in runtime (not during tests) that called thread-race-test .
|
|
Do you have any advices how to test a multithreaded application?
I know, threading errors are very difficult to catch and they may occur at anytime - or not at all. Tests are difficult and the results are never for sure. Certainly it is best to carefully...
Started by tanascius on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Generally use some good tools to test ....
Create a test document or spreadsheet, and using your people from the hall and do a 'hallway usability test' (Joel on Software said that I think?).
Counts, etc and make sure they make sense.
|
|
I am writing a unit test for some thread locking logic, so as to make the test more likely to fail quickly; I wish to have all the threads switch between each other very often and at random times.
I know this will not prove we don’t have any bugs, but...
Started by Ian Ringrose on
, 6 posts
by 6 people.
Answer Snippets (Read the full thread at stackoverflow):
The writer feels the sameTake a look at....
[UPDATE] Look at this answer in this thread .
This question is not about a thread shaker more like a special test to me.
Is a more effective way to test thread locking logic.
|
|
When testing with Visual Studio Team Test unhandled exceptions in tests are caught and reported in the results. So I was kind of surprised to see the test hosting process (VSTestHost.exe) crash and showing the system crash dialog.
Upon further investigation...
Started by gix on
, 7 posts
by 7 people.
Answer Snippets (Read the full thread at stackoverflow):
However you will need a way to block the unit test thread until BackgroundWorker completes the work know how that interacts with the VS test harness thought
Generally I try to avoid starting threads in unit tests ....
|