Testing multithreading (#9193)

This commit is contained in:
Kumar Chandrakant
2020-04-28 09:48:00 +05:30
committed by GitHub
parent 0a620333df
commit 6370f2ae4a
12 changed files with 90 additions and 135 deletions

View File

@@ -0,0 +1,22 @@
package com.baeldung.concurrent;
public class MyCounter {
private int count;
public void increment() {
int temp = count;
count = temp + 1;
}
public synchronized void incrementWithWait() throws InterruptedException {
int temp = count;
wait(100);
count = temp + 1;
}
public int getCount() {
return count;
}
}