Please enable JavaScript.
Coggle requires JavaScript to display documents.
thread basics - Coggle Diagram
thread basics
what?
basic unit of scheduling
allow multiple stream of control flow to co-exists in a process
allow natural decomposition for exploiting hardware parallelism
diagram
benefits
exploit multiple processor
handling of asynchronous events
can be handled by
blocking IO
thread is blocked until data arrives and is read
can be used as modern OS allow large number of threads per process
non-blocking IO
thread is not blocked
more complicated and error prone than blocking IO
responsive UI
GUI used to be single threaded
modern GUI framework use multiple thread
risks
safety hazard
mutating operation on different thread may lead to inconsistent data
threads share same memory space
must synchronize shared resource
liveness hazard
when a thread enters into a state from which it can't go forward
thread A wait for resource which is locked by thread B indifinitely