Bonjour,
Je n'arrive pas à trouver pourquoi, ma méthode wake(), ne réveille pas la méthode wait(). Le réveille s'effectue seulement au bout du délai fixé dans wait(delai). Quelqu'un aurait il une solution svp?
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 public class ThreadPartie extends Thread { Partie p; long delai; public ThreadPartie(Partie p, long delai) { this.p = p; this.delai = delai; } public synchronized void wake(){ this.notify(); } public synchronized void run() { try { // pause wait(delai); } catch (InterruptedException ex) { } System.out.println("fin"); } } } public class Principale { public static void main(String[] args) { Dictionnaire d = new Dictionnaire("dictionnaire"); Partie p = new Partie(d,0,200000,1); ThreadPartie t = new ThreadPartie(p,10000); t.start(); t.wake(); } }
Partager