Chapter 15. Using Threads


15. Using Threads

Threading is the way in which a software application carries on multiple processes at the same time. A thread in Java is a unit of program execution that runs concurrently with other threads.

Threads are commonly used in GUI applications. In a GUI application, one thread might be listening for input from the keyboard or other input devices, while another thread is processing the previous command. Networking is another common area in which you will find multithreading used. In network programming, one thread might be listening for connection requests, while another thread processes a previous request. Timers are also common uses of threads. A timer can be started as a thread running independently from the rest of an application. In all these examples, multithreading enables an application to carry on with processing while also executing another task that might take a longer amount of time and would cause long delays if not for multithreading.

Java has very good built-in support for writing multithreaded applications. Writing a multithreaded application was a very complex task in the C language, but in Java, writing a multi-threaded application is a much easier task.




JavaT Phrasebook. Essential Code and Commands
Java Phrasebook
ISBN: 0672329077
EAN: 2147483647
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net