Skip to content

Commit f70382a

Browse files
committed
Update volatile-keyword.md
1 parent d8e62de commit f70382a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

notes/volatile-keyword.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ That means, that each thread may copy the variables into the CPU cache of differ
1919

2020
With non-volatile variables there are no guarantees about when the Java Virtual Machine (JVM) reads data from main memory into CPU caches, or writes data from CPU caches to main memory.
2121

22-
Imagine a situation in which two or more threads have access to a shared object which contains a counter variable declared like this:
22+
Imagine a situation in which two or more threads have access to a shared object which contains a `counter` variable declared like this:
2323

2424
```java
2525
public class SharedObject {
@@ -60,4 +60,4 @@ Declaring a variable `volatile` thus _guarantees the visibility_ for other threa
6060

6161
In the scenario given above, where one thread (T1) modifies the `counter`, and another thread (T2) reads the `counter` (but never modifies it), declaring the `counter` variable `volatile` is enough to guarantee visibility for T2 of writes to the `counter` variable.
6262

63-
If, however, both T1 and T2 were incrementing the counter variable, then declaring the `counter` variable `volatile` would not have been enough.
63+
If, however, both T1 and T2 were incrementing the `counter` variable, then declaring the `counter` variable `volatile` would not have been enough.

0 commit comments

Comments
 (0)