Libraryless. Click here for Pure Java version (4687L/26K).
sclass AutoVMExit extends TimerTask { static boolean installed; static boolean disabled; int lastObjectCount = -1; static java.util.Timer timer; static int firstDelay = 30000; static int delay = 5000; public static void install() { if (!installed) { installed = true; if (!disabled) { timer = new java.util.Timer("AutoVMExit"); timer.scheduleAtFixedRate(new AutoVMExit(), firstDelay, delay); } } } /** Looks for objects that give us a reason to keep the VM alive. * Right now we count windows, tray icons and JavaFX stages. */ public void run() { if (isHiddenVM()) ret; int objectCount = autoVMExit_visibleObjects(); //System.out.println("Windows: " + objectCount); if (objectCount == 0 && lastObjectCount == 0) { System.out.println("AutoVMExit: No windows open or tray icons installed - exiting"); cleanKillVM(); //System.exit(0); } lastObjectCount = objectCount; } public static void disable() { disabled = true; if (timer != null) timer.cancel(); } public static int getFirstDelay() { return firstDelay; } public static void setFirstDelay(int firstDelay) { AutoVMExit.firstDelay = firstDelay; } public static int getDelay() { return delay; } public static void setDelay(int delay) { AutoVMExit.delay = delay; } }
Began life as a copy of #1007192
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033806 |
Snippet name: | AutoVMExit |
Eternal ID of this version: | #1033806/1 |
Text MD5: | bf5ab8d49555b61090a2813c33e30dd7 |
Transpilation MD5: | ba0eefbbe2472e76f996476054ac2e33 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-05 05:10:54 |
Source code size: | 1443 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 176 / 253 |
Referenced in: | [show references] |