File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
lab_02/src/main/java/lab_02 Expand file tree Collapse file tree 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) {
171171 public void handle (ActionEvent e ) {
172172 if (isPause ) {
173173 pauseBtn .setText ("Resume" );
174- threadFlag = false ;
175174 isPause = false ;
176175 } else {
177176 pauseBtn .setText ("Pause" );
178- threadFlag = true ;
179177 isPause = true ;
180178
181- stop ();
182- start ();
179+ synchronized (t ) {
180+ t .notify ();
181+ }
183182 }
184183
185184 pauseBtn .setDisable (false );
@@ -221,6 +220,16 @@ public void run() {
221220 System .out .println ("Clock is starting!" );
222221
223222 while (threadFlag ) {
223+ if (!isPause ) {
224+ synchronized (t ) {
225+ try {
226+ t .wait ();
227+ } catch (InterruptedException ee ) {
228+ ee .printStackTrace ();
229+ }
230+ }
231+ }
232+
224233 try {
225234 Platform .runLater (new Runnable () {
226235 @ Override public void run () {
You can’t perform that action at this time.
0 commit comments