So I have a thread running like this:
Runnable runnable = new Runnable() {
@Override
public void run() {
System.out.println("redo groupMonitor ... ");
if (redogmSafer < 1) {
groupMonitor.run(remoteHost, port);
} else {
}
redogmSafer = 100;
}
};
ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(runnable, 0, delayStart, TimeUnit.MILLISECONDS);
if (redogmSafer < 1) {
} else {
service.shutdown();
service.shutdownNow();
redogmSafer = 0;
}
And I want to run()
the Thread
again, after it has exited due to an exception or else(Happens all 4-5 Hours).
I have tried to shutdown()
and shutdownNow()
, but that doesn't help either. It's like Java doesn't want to redo Threads once it has started been started and shutdown ...