Skip to content

Commit d2aa347

Browse files
committed
Update App.java
Added comment.
1 parent ae7cf19 commit d2aa347

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • JavaMultiThreadingCodes/src/VolatileKeyword_2

JavaMultiThreadingCodes/src/VolatileKeyword_2/App.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
* </a>
1616
*
1717
* @author Z.B. Celik <celik.berkay@gmail.com>
18+
*
19+
* Normally, the below program will stop running after you
20+
* press return. But in some system it won't. As after
21+
* Java optimize the code, one thread doesn't expect other
22+
* thread to modify its fields, that is the value of
23+
* running. So to guarantee it works on all system or OS,
24+
* we use volatile. It prevents cache caching the variables.
1825
*/
1926
import java.util.Scanner;
2027

0 commit comments

Comments
 (0)