some changes in methods
[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                 closure()\r
23         }\r
24 \r
25         def runAfter(long delay, Closure closure) {\r
26                 /*thread = new Thread() {\r
27         \r
28                         @Override\r
29                         public void run() {\r
30                                 Thread.sleep(delay)\r
31                                 closure()\r
32                         }\r
33                 }.start()\r
34                 return thread*/\r
35                 closure()\r
36         }\r
37 \r
38         def cancel() {\r
39                 //if (thread != null)\r
40                 //      thread.stop()\r
41         }\r
42 }\r