File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ but others are unique.
24
24
25
25
### The problem
26
26
27
- Let us launch a hundred coroutines all doing the same action thousand times.
27
+ Let us launch a hundred coroutines all doing the same action a thousand times.
28
28
We'll also measure their completion time for further comparisons:
29
29
30
30
<div class =" sample " markdown =" 1 " theme =" idea " data-highlight-only >
@@ -102,7 +102,7 @@ increment the `counter` concurrently from multiple threads without any synchroni
102
102
103
103
### Volatiles are of no help
104
104
105
- There is common misconception that making a variable ` volatile ` solves concurrency problem. Let us try it:
105
+ There is a common misconception that making a variable ` volatile ` solves concurrency problem. Let us try it:
106
106
107
107
<!-- - CLEAR -->
108
108
@@ -158,7 +158,7 @@ do not provide atomicity of larger actions (increment in our case).
158
158
### Thread-safe data structures
159
159
160
160
The general solution that works both for threads and for coroutines is to use a thread-safe (aka synchronized,
161
- linearizable, or atomic) data structure that provides all the necessarily synchronization for the corresponding
161
+ linearizable, or atomic) data structure that provides all the necessary synchronization for the corresponding
162
162
operations that needs to be performed on a shared state.
163
163
In the case of a simple counter we can use ` AtomicInteger ` class which has atomic ` incrementAndGet ` operations:
164
164
You can’t perform that action at this time.
0 commit comments