File tree 1 file changed +13
-4
lines changed
lab_02/src/main/java/lab_02
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -171,15 +171,14 @@ public void handle(ActionEvent e) {
171
171
public void handle (ActionEvent e ) {
172
172
if (isPause ) {
173
173
pauseBtn .setText ("Resume" );
174
- threadFlag = false ;
175
174
isPause = false ;
176
175
} else {
177
176
pauseBtn .setText ("Pause" );
178
- threadFlag = true ;
179
177
isPause = true ;
180
178
181
- stop ();
182
- start ();
179
+ synchronized (t ) {
180
+ t .notify ();
181
+ }
183
182
}
184
183
185
184
pauseBtn .setDisable (false );
@@ -221,6 +220,16 @@ public void run() {
221
220
System .out .println ("Clock is starting!" );
222
221
223
222
while (threadFlag ) {
223
+ if (!isPause ) {
224
+ synchronized (t ) {
225
+ try {
226
+ t .wait ();
227
+ } catch (InterruptedException ee ) {
228
+ ee .printStackTrace ();
229
+ }
230
+ }
231
+ }
232
+
224
233
try {
225
234
Platform .runLater (new Runnable () {
226
235
@ Override public void run () {
You can’t perform that action at this time.
0 commit comments