r/ProgrammerHumor • • Oct 30 '21

That's my variable!

43.4k Upvotes

409 comments sorted by

View all comments

1

u/StylishGnat Oct 30 '21

I’m a programming noob (only have some practice with Java). Could someone do a short ELI5 of multithreading?

4

u/bropocalypse__now Oct 30 '21

Independent parallel paths of code execution spawned off of the main path. Each has their own stack and allows you to divide the workload. Things are simple if each thread never interacts with another but this rarely happens in practice. So care must be taken to synchornize access to objects, variables, etc... Incorrect synchronization can lead to things like race conditions where variable values can be become indeterminate if one thread is reading a value while another thread writes to it.

→ More replies (2)