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
|
public class MoniteurZic extends Applet{
private boolean pasZic = true;
AudioClip morceau= getAudioClip(getDocumentBase(),"tonmorceau");
class Chrono extends Thread {
int duree;
public Chrono(int d) {duree=d;}
public void run() {
try {sleep(duree);} catch (InterruptedException e) {}
notify();
}
}
Joueur j;
public void start () {
j=new Joueur(); j.start();
}
synchronized void attendre() {
try{wait();} catch(InterruptedException e){}
}
static void prononce(AudioClip audio, int duree) {
audio.play(); try {Thread.sleep(duree);} catch (InterruptedException e){}
}
class Joueur extends Thread {
public void run() {
synchronized(MoniteurZic.this){
while (true) {
Chrono c = new Chrono(5000);
c.start();
attendre();
prononce(morceau,3000);
}
}
}
}
} |
Partager