Thread
Dear Members,
Can anyone please tell me, What is thread in Java and it's usage ? |
thread is a flow of control within a program. A thread is similar to the more familiar notion of a process, except that multiple threads within the same application share much of the same state--in particular, they run in the same address space. It's not unlike a golf course, which can be used by many players at the same time. Sharing the same address space means that threads share instance variables, but not local variables
A new thread is born when we create an instance of the java.lang.Thread class. The Thread object represents a real thread in the Java interpreter and serves as a handle for controlling and synchronizing its execution. With it, we can start the thread, stop the thread, or suspend it temporarily. |
Quote:
The operating system can run a lot of programs (processes) and a program can run a lot of threads. Typically threads are used to do background work in a program. At any given time, there may be many such background threads, performing activities in parallel in an application, like requesting images, updating the screen, playing audio, and so on. But often the threads provide the only way to effectively handle a number of tasks. That is why it is important to understand and to know how to use threads in concurrent programming in Java. |
All times are GMT -7. The time now is 01:34 AM. |
Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.