What is multithreading?
concurrent/parallel programming–a way to have multiple different sets of instructions running at once
Why is multithreading useful?
to increase efficiency of application; caveat: for many applications, complexity of multithreading outweighs the benefits
Problems Common to Multithreading
multithreading introduces a lot of problems because it’s very easy for different sets of instructions to interfere with one another; maybe they’re competing for a resource, maybe operating in different orders
Race conditions
output of application is dependent on order in which threads execute (unpredictable output, may or may not throw exception/error)
Deadlock
2 resources acquired in different orders, and threads do not relinquish these resources (a standoff)
Starvation
a thread acquires a resource and does not release
Livelock
two threads are competing for resources and are trapped in a feedback loop (hot potato)
How can issues in multithreading be addressed?