multithreading - How to "try start" one thread from several other threads, java -
i wrote in function:
if(mythread.isalive()) { } else { mythread.start(); }
but unsafe if many threads call function same time. start running thread throws exception.
so except putting try-catch around it, have other options?
make method synchronized. also, check (isalive()
) unsafe because if thread have been finished cannot start again (and isalive()
return false...)
Comments
Post a Comment