What Is a Thread?

Imagine the multitasking waiter is your computer's processor and the customers are tasks. Each task runs in its own thread, and a processor with a modern operating system can run many threads concurrently. For example, you've probably downloaded a file from the Internet while writing a paper at the same time. Modern operating systems run threads concurrently by splitting a thread's task into smaller chunks. This is called concurrency. One thread is executed for a small amount of time (time slices). Then the thread is pre-empted, enabling another thread to run, and so on, as shown in Screenshot. The time slices are small enough so that it seems as if several things are happening at once.

Screenshot Concurrency means running multiple threads on one processor.

Java graphics 01fig01.gif


On machines with more than one processor, threads might actually run simultaneously, depending on the JVM implementation.



   
Comments