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

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -