The former is called preemptive multitasking; the latter is called cooperative (or, simply, nonpreemptive) multitasking. Shows an animated bouncing ball running in a separate thread 9.
After all, when you are reading data over a network connection, it is all too common to be stuck in a task that you would really like to interrupt.
For example, suppose you download a large image and decide, after seeing a piece of it, that you do not need or want to see the rest; you certainly would like to be able to click on a "Stop" or "Back" button to interrupt the loading process.
(Although harder to implement, preemptive multitasking is much more effective.
With cooperative multitasking, a badly behaved program can hog everything.) Multithreaded programs extend the idea of multitasking by taking it one level lower: individual programs will appear to do multiple tasks at the same time. NOTE Since most computers do not have multiple processors, the Java virtual machine (JVM) uses a mechanism in which each thread gets a chance to run for a little while, then activates another thread.
If you become tired of the bouncing ball before it has finished its 1,000 bounces and click on the "Close" button, the ball continues bouncing anyway.