1 | static int updateLoop_defaultInterval = 5000; |
2 | |
3 | static void updateLoop(int interval) {
|
4 | updateLoop_defaultInterval = interval; |
5 | updateLoop(); |
6 | } |
7 | |
8 | static void updateLoop() {
|
9 | thread "update loop" {
|
10 | while (true) {
|
11 | try {
|
12 | update(); |
13 | } catch (Throwable e) {
|
14 | e.printStackTrace(); |
15 | } |
16 | Integer interval = cast getOpt(getMainClass(), "updateInterval"); |
17 | sleep(interval == null || interval == 0 ? updateLoop_defaultInterval : interval); |
18 | } |
19 | } |
20 | } |
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: | 877 / 1329 |
| Referenced in: | [show references] |