()
| 309 | |
| 310 | public void exit() { |
| 311 | try { |
| 312 | if (exitStarted.compareAndSet(false, true)) { |
| 313 | for (Runnable r : onExit) { |
| 314 | try { |
| 315 | r.run(); |
| 316 | } catch (Throwable t) { |
| 317 | System.err.println(" exception thrown during exit (will continue on regardless)"); |
| 318 | t.printStackTrace(); |
| 319 | } |
| 320 | } |
| 321 | if (Thread.currentThread() != shutdownThread) System.exit(0); |
| 322 | } |
| 323 | } catch (Throwable t) { |
| 324 | System.err.println(" unexpected exception thrown during exit "); |
| 325 | t.printStackTrace(); |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * adds a Runnable to be executed on exit. This will run before anything else that's been added. |
| 331 | */ |
no test coverage detected