Hi folk.
Can I use join() method in implementation of run(), like this:
public class MyThread extends Thread {
@Override
public void run()
{
int timeout = 30000;
// here is some heavy work
join(timeout);
}
}
Is above thread terminated after timeout milliseconds if task takes longer time?
I'm planning to use this thread with thread pool and want to terminate it if task takes longer time than timeout.
ExecutorService executor = Executors.newFixedThreadPool(10);
MyThread mythr = new MyThread();
executor.execute(mythr);
Please, give me some suggestions...