Skip to content

Commit 8e99bf8

Browse files
authored
Fix/lab 02 (#6)
* Fixed time label * Fixed thread
1 parent 5861ff3 commit 8e99bf8

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lab_02/src/main/java/lab_02/App.java

+13-4
Original file line numberDiff line numberDiff 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() {

0 commit comments

Comments
 (0)