我们有一个带有 ServletContextListener 的 Web 应用程序,它启动多个 ScheduledExecutorService 以通过远程位置的 SNMP 更新一些中继板,而不是运行 Web 应用程序的服务器。
但是,由于远程位置的 Internet 连接丢失,远程中继板可能不可用。
发生这种情况时,更新板的线程需要很长时间才能执行。如何监控 ScheduledExecutorService 的执行和运行?
现在我使用以下代码启动线程:
schedulerLichtsturing = Executors.newSingleThreadScheduledExecutor();
schedulerLichtsturing.scheduleAtFixedRate(new LichtsturingDaemon(), 0, 15, TimeUnit.SECONDS);
但是我已经看到线程在一段时间后不再运行,我不知道它为什么停止。由于未捕获的异常或其他原因?我怎样才能监控这个?
我还想监视线程的运行状态以及上次更新的时间。
我应该如何解决这个问题?