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
| public class Horloge
{
Timer mon_Timer;
Thread threadmain;
public Horloge(int Secondes, Thread threadmain)
{
mon_Timer = new Timer();
this.threadmain = threadmain;
mon_Timer.schedule(new
Tache_Reveil(),Secondes*1000);
System.out.println("Chrono lancé !");
}
class Tache_Reveil extends TimerTask
{
@SuppressWarnings("deprecation")
public void run()
{
System.out.println("90 s écoulées");
mon_Timer.cancel();
threadmain.destroy();
while (true)
{
//bloque le programme ici
}
}
}
} |
Partager