projects
/
smartthings-infrastructure.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
a13376610f5f56f26341e4a6cb4f666332c25a2c
[smartthings-infrastructure.git]
/
Timer
/
SimulatedTimer.groovy
1
//Create a class for timer
\r
2
package Timer
\r
3
\r
4
public class SimulatedTimer {
\r
5
private Thread thread;
\r
6
\r
7
SimulatedTimer() {
\r
8
thread = null;
\r
9
}
\r
10
\r
11
//By Apps
\r
12
def runAfter(int delay, Closure closure) {
\r
13
thread = new Thread() {
\r
14
\r
15
@Override
\r
16
public void run() {
\r
17
Thread.sleep(delay)
\r
18
closure()
\r
19
}
\r
20
}.start()
\r
21
return thread
\r
22
}
\r
23
\r
24
def cancel() {
\r
25
if (thread != null)
\r
26
thread.stop()
\r
27
}
\r
28
}
\r