Please enable JavaScript.
Coggle requires JavaScript to display documents.
Concurrency - Coggle Diagram
Concurrency
concepts
thread vs process
thread
process
process
program
main thread
multi-threading
concurrency
process level
many programs
browser
music player
word editor
thread level
may tasks
checking
used threads
Thread.activeCount()
2 threads
main()
garbage collector
available threads
Runtime.getRuntime().availableProcessors()
current thread
Thread.currentThread()
getName()
getId()
thread-safe code
working with threads
operations
start new one
new Thread()
start()
killed automatically
Runnable Interface
pause a thread
Thread.sleep()
joining threads
single thread
targetThread.join()
when
current thread waiting for target thread
blocking action
multiple threads
save to thread list
loop and join
interrupt threads
thread.interrupt()
InterruptedExecution
interrupt a sleeping thread
send a request only
Thread.currentThread().isInterrupted()
check for the interrupting signal
manually stop thread
Thread sheduler
tasks > threads
JVM
switching between threads
what threads run for how long
concurrency issues
problems
visibility problem
Race Conditions
multiple threads competing
modify same resource
thread-safe code
confinement
immutability
synchronization
deadlock
atomic objects
partitioning
why
multi-core processors
optimize
1 core
2 threads
atomic objects
non-atomic
multiple steps
total++;
synchronization
volatile fields