![]() |
![]() |
|
02158 Concurrent Programming Fall 2024 |
Mini Lab 2: Shared variables in Java |
Home | Plan | Material |
To experience the race condition problem with shared variables in Java.
See the note about processes and threads [Proc 4] description of threads in Java.
[The volatile-modifier on a variable declaration
ensures that any change of the variable is actually written to the
variable (and not just held in a register for optimization).]
[If you get the same (correct) result every time, try the following:
Explain the varying results.
Enjoy!
Hans Henrik Løvengreen, Sep 11, 2024 |