Site Owners Forums - Webmaster Forums

Site Owners Forums - Webmaster Forums (http://siteownersforums.com/index.php)
-   Java (http://siteownersforums.com/forumdisplay.php?f=12)
-   -   Thread (http://siteownersforums.com/showthread.php?t=63920)

saurabh mishra 02-27-2013 12:55 AM

Thread
 
Dear Members,
Can anyone please tell me, What is thread in Java and it's usage ?

amitsharma11 10-09-2013 11:24 PM

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.

alligatortek001 02-26-2014 12:57 AM

Quote:

Originally Posted by saurabh mishra (Post 253891)
Dear Members,
Can anyone please tell me, What is thread in Java and it's usage ?

A thread can be defined as a flow of control within a program. The notion of thread is similar to the more familiar notion of process. The difference between a thread and a process becomes clear when we think about the visualization of system resources. A process visualizes the operating system resources - a process considers that it owns all the system resources. A thread however visualizes only the program resources - a thread considers that it owns all address space of the program.
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.