Skip to content

refactor: improving code and docs for Atomic examples #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* AtomicReferenceArray provides atomic operations on arrays of reference values.
*/
public class AtomicReferenceArrayExample {


/**
* An AtomicReferenceArray named array is created with an initial size of 3 and populated with initial values.
* The updater thread updates the value at index 1 of the array using the compareAndSet method, which atomically compares the current value with an expected value and sets the new value if the comparison is successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public void setData(String data) {
}
}


/**
*
* Demonstrates how AtomicReference ensures atomic updates of a shared reference in a multithreaded environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ static class MyClass {
volatile String value;
}


/**
* MyClass is a simple class with a volatile reference field named value.
* An AtomicReferenceFieldUpdater named updater is created for the value field of MyClass.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public class OddEvenPrinterExample {
* @param args command line arguments (not used)
*/
public static void main(String[] args) {
Thread oddThread = new Thread(() -> printOddNumbers());
Thread evenThread = new Thread(() -> printEvenNumbers());
Thread oddThread = new Thread(OddEvenPrinterExample::printOddNumbers);
Thread evenThread = new Thread(OddEvenPrinterExample::printEvenNumbers);

oddThread.setName("OddThread");
evenThread.setName("EvenThread");
Expand Down