Bonsoir les hommes forts,

J'ai un problème d'Exception avec le Thread suivant après exécution. Voici le code.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
public class TonAlarm extends Thread{
	TonAlarm(){}
	public void run(){
		String cond="P1Y"; //2M3DT10H30M";
		int tailleCond=0;
		int nbA=0, nbM=0, nbJ=0, nbH=0, nbMn=0;
		long nbAnneeMis=0,nbMoisMis=0, nbJourMis=0, nbHeureMis=0, nbMinuteMis=0;
		int a=cond.indexOf("Y");
		if(a>0){
			String nbAnnee=cond.substring(1, a);
			nbA=Integer.parseInt(nbAnnee);
			tailleCond=a+nbAnnee.length();
			nbAnneeMis=86400000*30*12*nbA;
		}
		int m=cond.indexOf("M");
		if (m>0){
			String nbMois=cond.substring(a+1, m);
			nbM=Integer.parseInt(nbMois);
			tailleCond=m+nbMois.length();
			nbMoisMis=86400000*30*nbM;
		}
		int j=cond.indexOf("D");
		if(j>0){
			String nbJour=cond.substring(m+1, j);
			nbJ=Integer.parseInt(nbJour);
			tailleCond=j+nbJour.length();
			nbJourMis=86400000*nbJ;
		}
		int h=cond.indexOf("H");
		if(h>0){
			String nbHeure=cond.substring(j+2, h);
			nbH=Integer.parseInt(nbHeure);
			tailleCond=h+nbHeure.length();
			nbHeureMis=3600000*nbH;
		}
		if(tailleCond<cond.length()){
			String nbMinute=cond.substring(h+1, (cond.length()-1));
			nbMn=Integer.parseInt(nbMinute);
			nbMinuteMis=60000*nbMn;
		}
		long attente=nbAnneeMis+nbMoisMis+nbJourMis+nbHeureMis+nbMinuteMis;
		try {
			wait(attente);
		} catch (InterruptedException e) {
			// TODO Bloc catch auto-généré
			e.printStackTrace();
		}
 
	}
	public static void main(String arg0[]){
		boolean fin=true;
		TonAlarm th=new TonAlarm();
		String vMess="";
		System.out.print("Entrer un message :");
		vMess=Clavier.lireString();
		while(fin){	
			if (vMess.equalsIgnoreCase("mali")) {
				System.out.println("Vous êtes au Mali !");
				fin=false;}
			else{
				if (vMess.equalsIgnoreCase("senegal")) {
					System.out.println("Vous êtes au senegal !");
					fin=false;}
				else {
					th.start();
					System.out.println("Thread Alarm lancé et terminé !");}
			}
		}
	}
 
}
Voici le message d'erreur après exécution.

Thread Alarm lancé et terminé ! (mon message à afficher)
Exception in thread "main" java.lang.IllegalThreadStateException
at java.lang.Thread.start(Unknown Source)
at TonAlarm.main(TonAlarm.java:66)
Exception in thread "Thread-0" java.lang.IllegalMonitorStateException: current thread not owner
at java.lang.Object.wait(Native Method)
at TonAlarm.run(TonAlarm.java:44)