The Runnable Object Classes
As explained in Introducing the Runnable, the runnable family of classes includes the basic mechanisms used to create, control, and monitor the threads of execution within your application.
In a synchronous runnable, the thread that calls start() is the same thread that executes run(); the flow of control is simply passed internally from the start() member to the run() member. By the time the start() function returns, the runnable has completed (or at least attempted to perform) its specified task, as shown in Figure 5.
Figure 5 – Synchronous runnable
In a threaded runnable, a call to start() results in the creation of a new thread of execution, as shown in Figure 6. Following creation, this new thread proceeds to execute the run() member, freeing the thread that called start() to move on to other things.
Figure 6 – Threaded runnable
In this guide, any thread that is currently executing within a runnable’s run() member is commonly referred to as being inside that runnable. The Threading package allows only one thread at a time to be inside, or active, within a runnable. All other threads are considered to exist outside the runnable.