1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public class Demo{
Timer t;
private static Demo MyDemo = null; // Singleton
/**
* Constructor
*/
private Demo(){
}
/**
* Return the Singleton of Demo
* @return Demo
*/
public static Demo getInstance(){
if(MyDemo==null)
MyDemo = new Demo();
return MyDemo;
}
/**
* To stop the demo mode
*/
protected void Stop() {
System.out.println("Arret du mode demo");
t.cancel();
t=null;
//t = new Timer();
//t.schedule(new MonAction(), 99999, 10000);
}
/**
* To start the demo mode
*/
protected void Start() {
System.out.println("Demarrage du mode demo");
t = new Timer();
t.schedule(new MonAction(), 1, 10000);
}
/**
* Timer for the demo mode
*/
class MonAction extends TimerTask {
public void run() {
// Mon code qui doit tourner en boucle et qui doit s'arrêt lorsque
}
}
} |
Partager