回答編集履歴

2

修正

2020/06/12 00:58

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -9,6 +9,8 @@
9
9
  #include <mutex>
10
10
 
11
11
  #include <chrono>
12
+
13
+ #include <atomic>
12
14
 
13
15
 
14
16
 
@@ -22,7 +24,13 @@
22
24
 
23
25
  mutex mtx;
24
26
 
27
+ /* 修正: int→atomic<int>
28
+
29
+ read時にmutexで排他してないので。
30
+
31
+ int値のreadは実質atomicに行われるだろうから"まず"大丈夫なんだろけど念のため */
32
+
25
- int shop_apple = 100;
33
+ atomic<int> shop_apple = 100;
26
34
 
27
35
 
28
36
 

1

微修正

2020/06/12 00:58

投稿

episteme
episteme

スコア16614

test CHANGED
@@ -1,3 +1,5 @@
1
+ リアルタイムにリンゴの買い出しさせてみた。
2
+
1
3
  ```C++
2
4
 
3
5
  #include <iostream>