Working with threads
Let’s finally get to explaining threads. Threads are sequences of executed instructions, representing the most fundamental units of execution. Each thread follows a certain path through the code. The threads perform specific tasks within processes. A process is typically composed of multiple threads.
To give you an example, the programs we’ve created so far had one user-created thread (and the user in this case is the developer). The thread went through the lines of code in a certain order; for example, when a method was called, the thread would execute that method before continuing with the code that was directly on the next line after the method call. This is the path of execution of the thread.
When multiple threads are running, multiple paths of execution are being walked through your code, and that’s why multiple things are happening at the same time.
In order to make this possible, we’ll need duplicates of certain Java...