static int updateLoop_defaultInterval = 5000; static void updateLoop(int interval) { updateLoop_defaultInterval = interval; updateLoop(); } static void updateLoop() { thread "update loop" { while (true) { try { update(); } catch (Throwable e) { e.printStackTrace(); } Integer interval = cast getOpt(getMainClass(), "updateInterval"); sleep(interval == null || interval == 0 ? updateLoop_defaultInterval : interval); } } }
Optionally uses a variable called "updateInterval". Default is 5000 ms.
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001746 |
Snippet name: | updateLoop - requires a function called "update" |
Eternal ID of this version: | #1001746/1 |
Text MD5: | 58575237eb63cdbda6c7296280570e9d |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-11-12 21:47:00 |
Source code size: | 544 bytes / 20 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 651 / 1099 |
Referenced in: | [show references] |