Home Java Thread Threading in Java
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Threading in Java

Advertisement
Threading concept is very important in Java Programing language. A thread is a sequential path of code execution within a program. And each thread has its own local variables, program counter and lifetime.

Threading in Java

       

  1. Overview of Thread
    Threading concept is very important in Java Programing language. A thread is a sequential path of code execution within a program. And each thread has its own local variables, program counter and lifetime.
     
  2. Life Cycle of A Thread
    Life Cycle of Thread contains different states  - New state, Runnable, Running state, Dead state, Non-Runnable state.

  3. Thread Creation 
    Thread can be implementing by one of two ways - Extending the java.lang.Thread Class, Implementing the java.lang.Runnable Interface.
      
  4. Thread Constructors
    Several constructors are available for creating new Thread instances like Thread(), Thread(String), Thread(Runnable) etc....
     
  5. Introduction to Multithreading
    Multithreading is a technique that allows a program or a process to execute many tasks concurrently (at the same time and parallel). It allows a process to run its tasks in parallel mode on a single processor system.

  6. Creation of Multiple Threads
    Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread or implementing interface Runnable.

  7. Thread Priorities and Scheduler
    In Java, thread scheduler can use the thread priorities in the form of integer value to each of its thread to determine the execution schedule of threads . Thread gets the ready-to-run state according to their priorities.

  8. Deadlock
    A situation where a thread is waiting for an object lock that holds by second thread, and this second thread is waiting for an object lock that holds by first thread, this situation is known as Deadlock.

  9. Lock and Synchronized Threads
    Java uses monitor also known as ?semaphore? to prevent data from being corrupted by multiple threads by a keyword synchronized to synchronize them and intercommunicate to each other. Lock term refers to the access granted to a particular thread that can access the shared resources.

  10. Inter-Thread Communication
    A process where, a thread is paused while running in its critical region and another thread is allowed to enter (or lock) in the same critical section to be executed.  This technique is known as Inter-Thread communication  
      
  11. Daemon Thread
    Daemon threads are service providers for other threads or objects running in the same process as the daemon thread. Daemon threads are used for background supporting tasks and are only needed while normal threads are executing
  12. Thread Synchronization in Java
    When two or more threads need shared resource, they need a proper mechanism to ensure that the resource will be used by only one thread at a time. The mechanism we use to achieve this is known as thread synchronization. 
Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Ask Questions?    Discuss: Threading in Java   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Hilal Ahmad
October 7, 2011
MCA

I am very intrested in java language
Siddharth
November 12, 2011
Java

I want a deep information about Reflection in Java. What is Use of Reflection ? How can we Use Reflection ?
somnath
January 19, 2012
thread

thanks
sarumathi
March 21, 2012
threading

need more information
mahendra
May 16, 2012
java

java support multiple inhertance? if yus then asked me......
pandi selvi
July 13, 2012
comment

I got good understading of the java concepts...
Chirag Gandhi
December 17, 2012
JAVA's topic

All point is easily explain on this site. understandable language.
nuzhat parveen
November 20, 2012
java ptoblem

java is very difficult for me.how shall i understand java?
jemal
January 4, 2013
op

it is not saiisfy
sohil
December 27, 2013
Copying a large file using threads in Java

HI I want to copy a large file using a few threads, I want to compare the time to copy a file to a thread by copying the same files with multi-threading. I want write this program with java. please guide me. thanks
DMCA.com