Thursday, December 3, 2015

Java - Multithreading


Java - Multithreading

Java is a multi threaded programming language which means we can develop multi threaded program using Java.A multi threaded program contains two or more parts that can run concurrently and each part can handle different task at the same time making optimal use of the available resources specially when your computer has multiple CPUs.



Eg Scenario : To make you all understand about thread i will use easy example 
its like this we will get google chrome as our programme. When we using chrome we will open new tabs while we using current tab.threads also like similar to chrome process. we can use thread to process different task at the same time.Hope you have proper idea about  Multithreading.













Process Behind the Multithreads :


  • Each thread having private run time stack
  • If multi thread execute in same method each threads will have their own copy of local variables & methods 


There are two ways to create a thread

  1. Sub-classing the THREAD class & instantiating a new object of the class
  2. Implementing the RUNNABLE interface
* But in both class we need to implement method  called run();

No comments:

Post a Comment