This repository contains all the reference implementations of the different locks and principles needed for the PProg exam.
Compile using:
javac *.java
Then you can run the concepts with their respective concept name:
java <ConceptName>
To see the outcome of the DataRace concept the commands would be the following:
javac *.java
java DataRace
Using two different methods to create threads, extending Thread and implementing Runnable.
Learning how to measure the time of executing threads using System.nanoTime().
Demonstrating the random order of parallel thread execution.
Showing the non-deterministic outcome when modifying the same data in parallel without any locks.
Ensuring the correct execution of the DataRace program by using the synchronized keyword.
Using this lock algorithm to ensure correct outcome of parallel modification of data. This algorithm only works when using the volatile keyword to prevent instruction reordering.
Using this lock algorithm to ensure correct outcome of parallel modification of data. This algorithm only works when using AtomicIntegerArrays.