Associate
My main thread creates new threads in a while loop as they are needed. To store the threads i keep them in a arraylist so i can reference them later.
But i want the main thread to clean up any threads which have stoped, and i can't think of a reasonable way todo this:
I can't use join, as the main thread doesn't know which will stop first, and i don't want it blocked whilst waiting for it anyway.
Ideally i'd want the terminating thread to call a cleanup function in the main thread (as a reference is passed to it to interact with the main thread whilst its running). But i can't terminate the thread from a method with is being called by it.
In c# i could use a delegate to make a nonblocking cross thread call to do this, but i don't think this is possible in java.
Any ideas would be appreciated.
But i want the main thread to clean up any threads which have stoped, and i can't think of a reasonable way todo this:
I can't use join, as the main thread doesn't know which will stop first, and i don't want it blocked whilst waiting for it anyway.
Ideally i'd want the terminating thread to call a cleanup function in the main thread (as a reference is passed to it to interact with the main thread whilst its running). But i can't terminate the thread from a method with is being called by it.
In c# i could use a delegate to make a nonblocking cross thread call to do this, but i don't think this is possible in java.
Any ideas would be appreciated.