File tree Expand file tree Collapse file tree 2 files changed +17
-36
lines changed
src/main/java/bgu/spl/mics Expand file tree Collapse file tree 2 files changed +17
-36
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
package bgu .spl .mics ;
2
2
3
+ import java .util .Timer ;
3
4
import java .util .concurrent .TimeUnit ;
4
5
5
6
/**
@@ -48,6 +49,8 @@ public T get() {
48
49
public void resolve (T result ) {
49
50
this .result =result ;
50
51
isResolved =true ;
52
+ notifyAll ();
53
+
51
54
}
52
55
53
56
@@ -74,7 +77,20 @@ public boolean isDone() {
74
77
public T get (long timeout , TimeUnit unit ) {
75
78
//TODO: implement this.
76
79
// TODO: add a timer on another thread and call regular get()
77
- return null ;
80
+
81
+ long toWait =unit .toMicros (timeout );
82
+
83
+ if (isResolved )
84
+ return result ;
85
+
86
+ try {
87
+ wait (toWait );
88
+ } catch (InterruptedException e ) {
89
+ // TODO Auto-generated catch block
90
+ e .printStackTrace ();
91
+ }
92
+
93
+ return result ;
78
94
}
79
95
80
96
}
You can’t perform that action at this time.
0 commit comments