mirror of
https://github.com/Snailclimb/JavaGuide
synced 2025-06-16 18:10:13 +08:00
fix: 修改VolatileAtomicityDemo中的笔误
This commit is contained in:
parent
74ccdbcdab
commit
036445495d
@ -96,7 +96,7 @@ public class Singleton {
|
|||||||
* @author Guide哥
|
* @author Guide哥
|
||||||
* @date 2022/08/03 13:40
|
* @date 2022/08/03 13:40
|
||||||
**/
|
**/
|
||||||
public class VolatoleAtomicityDemo {
|
public class VolatileAtomicityDemo {
|
||||||
public volatile static int inc = 0;
|
public volatile static int inc = 0;
|
||||||
|
|
||||||
public void increase() {
|
public void increase() {
|
||||||
@ -105,11 +105,11 @@ public class VolatoleAtomicityDemo {
|
|||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
public static void main(String[] args) throws InterruptedException {
|
||||||
ExecutorService threadPool = Executors.newFixedThreadPool(5);
|
ExecutorService threadPool = Executors.newFixedThreadPool(5);
|
||||||
VolatoleAtomicityDemo volatoleAtomicityDemo = new VolatoleAtomicityDemo();
|
VolatileAtomicityDemo volatileAtomicityDemo = new VolatileAtomicityDemo();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
threadPool.execute(() -> {
|
threadPool.execute(() -> {
|
||||||
for (int j = 0; j < 500; j++) {
|
for (int j = 0; j < 500; j++) {
|
||||||
volatoleAtomicityDemo.increase();
|
volatileAtomicityDemo.increase();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user