I have a multi-threaded system in Java that uses the ThreadGroup
class that is deprecated.
With my current implementation I also can not "kill" a thread in lock. How to implement efficient code to control Thread
in Java?
I need to have minimal control over the runtime, startup, and completion of my% of threads%.
Simplified code for what needs to be done more efficiently:
int threadAtivas = 5;
ThreadGroup threadGroup = new ThreadGroup("threads");
while(true){
if(verificaQtdThreadsAtivas(threadGroup)){
criaNovaThread(threadGroup);
}else{
Thread.sleep(1000);
}
}