Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in...
Transcript of Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in...
![Page 1: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/1.jpg)
Java Atomic Classes & Operations:
Introduction
Douglas C. [email protected]
www.dre.vanderbilt.edu/~schmidt
Institute for Software
Integrated Systems
Vanderbilt University
Nashville, Tennessee, USA
![Page 2: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/2.jpg)
2
Learning Objectives in this Part of the Lesson• Understand how Java atomic classes &
operations provide concurrent programs with lock-free, thread-safe mechanisms to read from & write to single variables
![Page 3: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/3.jpg)
3
Learning Objectives in this Part of the Lesson• Understand how Java atomic classes &
operations provide concurrent programs with lock-free, thread-safe mechanisms to read from & write to single variables
• Note a human known use of atomic operations
![Page 4: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/4.jpg)
4
Overview of Java Atomic Classes
![Page 5: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/5.jpg)
5
Overview of Java Atomic Classes• The java.util.concurrent.atomic
package several types of atomic actions on objects
See docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/package-summary.html
![Page 6: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/6.jpg)
6
Overview of Java Atomic Classes• The java.util.concurrent.atomic
package several types of atomic actions on objects
• Atomic variables
• Provide lock-free & thread-safe operations on single variables
See docs.oracle.com/javase/tutorial/essential/concurrency/atomicvars.html
![Page 7: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/7.jpg)
7See docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html
Overview of Java Atomic Classes• The java.util.concurrent.atomic
package several types of atomic actions on objects
• Atomic variables
• Provide lock-free & thread-safe operations on single variables
• e.g., AtomicLong supportsatomic “compare-and-swap” operations
![Page 8: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/8.jpg)
8
Overview of Java Atomic Classes• The java.util.concurrent.atomic
package several types of atomic actions on objects
• Atomic variables
• LongAdder
• Allows multiple threads to update a common sum efficiently under high contention
See docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/LongAdder.html
![Page 9: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/9.jpg)
9
Overview of Atomic Operations
![Page 10: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/10.jpg)
10
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers
Overview of Atomic Operations
Additional Frameworks & Languages
Operating System Kernel
Applications
System Libraries
Java Virtual Machine
Threading & Synchronization Packages
Java
/JN
IC+
+/C
C
See software.intel.com/en-us/node/506090
![Page 11: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/11.jpg)
11See en.wikipedia.org/wiki/Compare-and-swap
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
Compare-and-swap atomically compares the current contents of a memory location to a given value & iff they are the same it modifies the contents
of that memory location to a given new value & returns the old value
![Page 12: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/12.jpg)
12
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
Compare-and-swap atomically compares the current contents of a memory location to a given value & iff they are the same it modifies the contents
of that memory location to a given new value & returns the old value
![Page 13: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/13.jpg)
13
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
Compare-and-swap atomically compares the current contents of a memory location to a given value & iff they are the same it modifies the contents
of that memory location to a given new value & returns the old value
![Page 14: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/14.jpg)
14
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
Compare-and-swap atomically compares the current contents of a memory location to a given value & iff they are the same it modifies the contents
of that memory location to a given new value & returns the old value
![Page 15: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/15.jpg)
15
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
Compare-and-swap atomically compares the current contents of a memory location to a given value & iff they are the same it modifies the contents
of that memory location to a given new value & returns the old value
![Page 16: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/16.jpg)
16
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
See en.wikipedia.org/wiki/Spinlock
The lock() method uses compareAndSwap() to implement mutual exclusion (mutex) via a “spin-lock”
![Page 17: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/17.jpg)
17
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
Overview of Atomic Operations
The lock() method uses compareAndSwap() to implement mutual exclusion (mutex) via a “spin-lock”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
compareAndSwap() must be called only once per lock attempt
![Page 18: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/18.jpg)
18
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
compareAndSwap() checks if the location pointed to by mutex is 0 & iff that’s true it sets the value to 1
![Page 19: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/19.jpg)
19
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
compareAndSwap() checks if the location pointed to by mutex is 0 & iff that’s true it sets the value to 1
![Page 20: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/20.jpg)
20
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
compareAndSwap() checks if the location pointed to by mutex is 0 & iff that’s true it sets the value to 1
![Page 21: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/21.jpg)
21
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
If compareAndSwap() returns 1 that means the mutex is “acquired” so the loop keeps spinning
![Page 22: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/22.jpg)
22
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
void unlock(int *mutex) {
START_ATOMIC();
*mutex = 0;
END_ATOMIC();
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
The unlock() method atomically resets the mutex value to 0
![Page 23: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/23.jpg)
23
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
void unlock(int *mutex) {
START_ATOMIC();
*mutex = 0;
END_ATOMIC();
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
The unlock() method atomicallyresets the mutex value to 0
![Page 24: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/24.jpg)
24
void lock(int *mutex) {
while (compareAndSwap(mutex, 0, 1) == 1)
continue;
}
void unlock(int *mutex) {
START_ATOMIC();
*mutex = 0;
END_ATOMIC();
}
• Atomics operations in Java are implemented in hardware with some support at the OS & VM layers, e.g.
• CAS – “compare-and-swap”
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
Overview of Atomic Operations
The unlock() method atomically resets the mutex value to 0
![Page 25: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/25.jpg)
25
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
See en.wikipedia.org/wiki/Test-and-set
• Atomic operations can be implemented other ways
• e.g., “test-and-set”
Overview of Atomic Operations
Test-and-set atomically modifies the contents of a memory location
& returns its old value
![Page 26: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/26.jpg)
26
• Atomic operations can be implemented other ways
• e.g., “test-and-set”
Overview of Atomic Operations
Test-and-set atomically modifies the contents of a memory location
& returns its old value
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
![Page 27: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/27.jpg)
27
• Atomic operations can be implemented other ways
• e.g., “test-and-set”
Overview of Atomic Operations
Test-and-set atomically modifies the contents of a memory location
& returns its old value
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
![Page 28: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/28.jpg)
28
• Atomic operations can be implemented other ways
• e.g., “test-and-set”
Overview of Atomic Operations
Test-and-set atomically modifies the contents of a memory location
& returns its old value
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
![Page 29: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/29.jpg)
29
void lock(int *loc) {
while (testAndSet(loc) == 1);
}
void unlock(int *loc) {
START_ATOMIC();
*loc = 0;
END_ATOMIC();
}
Test-and-set can also be used to implement a spin-lock mutex
Overview of Atomic Operationsint testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
• Atomic operations can be implemented other ways
• e.g., “test-and-set”
![Page 30: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/30.jpg)
30
Overview of Atomic Operations• compareAndSwap() provides a
more general solution than testAndSet()
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
See pages.cs.wisc.edu/~remzi/OSTEP/threads-locks.pdf
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
![Page 31: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/31.jpg)
31
Overview of Atomic Operations• compareAndSwap() provides a
more general solution than testAndSet()
• e.g., it can set the value to something other than 1 or 0
This capability is used by various Atomic* classes in Java
int compareAndSwap(int *loc,
int expected,
int updated) {
START_ATOMIC();
int oldValue = *loc;
if (oldValue == expected)
*loc = updated;
END_ATOMIC();
return oldValue;
}
int testAndSet(int *loc) {
int oldValue;
START_ATOMIC();
oldValue = *loc;
*loc = 1; // 1 == locked
END_ATOMIC();
return oldValue;
}
![Page 32: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/32.jpg)
32
Human Known Use of Atomic Operations
![Page 33: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/33.jpg)
33
Human Known Use of Atomic Operations • One “human” known use of atomic
operations is a Star Trek transporter
See en.wikipedia.org/wiki/Transporter_(Star_Trek)
![Page 34: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/34.jpg)
34
Human Known Use of Atomic Operations • One “human” known use of atomic
operations is a Star Trek transporter
• Converts a person/object into an energy pattern & “beams” them to a destination where they’re converted back into matter
![Page 35: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/35.jpg)
35
Human Known Use of Atomic Operations • One “human” known use of atomic
operations is a Star Trek transporter
• Converts a person/object into an energy pattern & “beams” them to a destination where they’re converted back into matter
• This process must occur atomically or a horrible accident will occur!
See en.wikipedia.org/wiki/Transporter_(Star_Trek)#Transporter_accidents
![Page 36: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/36.jpg)
36
Human Known Use of Atomic Operations • Another “human” known use of atomic
operations is “apparition” in Harry Potter
See harrypotter.fandom.com/wiki/Apparition
![Page 37: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/37.jpg)
37
Human Known Use of Atomic Operations • Another “human” known use of atomic
operations is “apparition” in Harry Potter
• If the user focuses properly they disappear from their current location & instantly reappear at the desired location
See harrypotter.fandom.com/wiki/Apparition
![Page 38: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/38.jpg)
38
Human Known Use of Atomic Operations • Another “human” known use of atomic
operations is “apparition” in Harry Potter
• If the user focuses properly they disappear from their current location & instantly reappear at the desired location
• However, “spinching” occurs if a wizard or witch fails to apparate atomically!
See harrypotter.fandom.com/wiki/Splinching
![Page 39: Java Atomic Classes & Operations: Introductionschmidt/cs891s/2020-PDFs/3...3 Learning Objectives in this Part of the Lesson •Understand how Java atomic classes & operations provide](https://reader034.fdocuments.net/reader034/viewer/2022042913/5f4c2cffc6af60198b7f4f35/html5/thumbnails/39.jpg)
39
End of Atomic Classes & Operations: Introduction