I have this scala code, which works just fine (run() is overridden in class)
val processRunnable = new myProcessClassWithOverriddenRunFunction()
val processThread = new Thread(processRunnable)
processThread.start
What I want to do is set a timeout for processThread thread. How can I do that?
I did some research and couldn't find any parameter we can pass to new Thread() or any function in processThread to achieve that.
Found some solutions on stackoveflow which implemented a ExecutorService but unfortunately, that is not implementable in this particular problem as making another new ExecutorService for just a single processThread, everytime this function is called seems inefficient. There are some other reasons as well but my question is how can I implement that functionality on this code?