Bonjour,
J'ai un petit problème dans une méthode run en cours de développement.
Je voudrais insérer 2blocs try-catch dans un autre bloc try-catch(qui les englobe donc).
Mais il me met comme erreur que une InterruptedException n'est jamais lancée dans le corps du try correspondant .
Or selon moi ce n'est pas le cas :s
Si quelqu'un pouvait m'aider ce serait sympa
Merci
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 public void run() { try{ synchronized(this){ try{ for ( int k = 0,plaque=0 ; k < 50; k++ , plaque++) { System.out.println ( "Je crée un objet " + k ); Voiture alpha = new Voiture(plaque); v.addElement(alpha); // g.addElement(alpha); System.out.println("taille du vecteur : "+v.size()); System.out.println ("plaque = "+plaque); delay = (int)((Math.random())*20000); Thread.sleep ( delay ); System.out.println("delay = "+delay); System.out.println("k = "+ k ); System.out.println("t = "+ t); }} catch( InterruptedException e ) { System.out.println("Interrupted Exception caught"); }} synchronized (this) { try {for (int j=0;j<v.size();j++){ int delay2 = (int)((Math.random())*38000); Thread.sleep(delay2); v.removeElementAt(j);} } catch(InterruptedException e){System.out.println("Interrupted Exception caught");}} } catch(InterruptedException e){System.out.println("Interrupted Exception caught");} }
Partager