We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 42476ff commit abfb57aCopy full SHA for abfb57a
2 files changed
src/main/java/core/basesyntax/Counter.java
@@ -6,7 +6,7 @@
6
public class Counter {
7
private static final Logger logger = LogManager.getLogger(Counter.class);
8
private static final String MESSAGE = "%20s, Thread # %2s, counter value %2d";
9
- private int value;
+ private volatile int value;
10
11
public Counter(int value) {
12
this.value = value;
src/main/java/core/basesyntax/Main.java
@@ -1,10 +1,13 @@
1
package core.basesyntax;
2
3
public class Main {
4
- public static void main(String[] args) {
+ public static void main(String[] args) throws InterruptedException {
5
Counter counter = new Counter(20);
+ Thread a;
for (int i = 1; i <= 20; i++) {
- new MyThread(counter, String.valueOf(i)).start();
+ a = new MyThread(counter, String.valueOf(i));
+ a.start();
+ a.join();
}
13
0 commit comments