123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Multithreading To Perform Multiple Task Simultaneously

Profile Picture
By Author: Infocampus
Total Articles: 33
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Multitasking : To process the multiple task simultaneously is known as multitasking.
By using two ways we can achieve the multitasking:
1)Process based Multitasking(Multiprocessing)
2)Thread based Multitasking (Multithreading)

Thread :
Thread is a lightweight sub-process, which are independent to each other.
To achieve the multitasking multiprocessing and multithreading is used.First we use multithreading then we use multiprocessing because threads share a common memory area.
MultiThreading :
Execution of multiple thread simultaneously is known as multithreading.
In games and animation generally we used the multithreading.
Advantages of multithreading :
1) It doesn’t stop the user because threads are independent with each other and we can perform multiple operations simultaneously.java training center bangalore
2) It saves time because we can perform multiple task simultaneously
3)Threads are independent with each other .So if any exception occur it doesn’t effect to other.

Life Cycle of Thread :
A thread can be in one of ...
... the five states.
The life cycle of the thread is controlled by JVM(JVM is nothing but Java Virtual Machine which convert byte code to machine code.).
The java thread states are given below:
1. New
2. Runnable
3. Running
4. Non-Runnable (Blocked)
5. Terminated
1)New State :
Once we create the instance of thread before the invocation of start() method , a thread will be in new state.java course in bangalore
2) Runnable State :
After the invocation of start() method , thread will be in runnable state.but the but the thread scheduler has not selected it to be the running thread.
3)Running State :
If the thread scheduler has selected that time thread will be in running state.
4) Non – Runnable State (Blocked State ):
When the thread is still alive but is not eligible to run that state is known as non-runnable state.
5) Terminated:
When thread’s run() metod exits it wil, be in terminatedor dead state.
Methods to create thread in java :
In java we can create thread using two ways -
Best core java training in bangalore
1.By extending Thread class
2.By implementing Runnable interface.
Thread Class :Thread class provides methods and constructors to create and perform operation on thread.
This class implements the Runnable interface or extends the Object class (Object class is the super most in java , all classes directly or indirectly inherit the Object class.)
Runnable Interface :
Runnable interface should be implemented by any class whose instances are intended to be executed by a thread. Runnable interface have only one method named run().
public void run(): is used to perform action for a thread.
How to start a thread :
start() method of Thread class is used to start a newly created thread.
It performs following operation
1)start the new thread
Advance java training in bangalore
2) Moves the thread from New state to the Runnable state.
3)When the thread gets a chance to execute, its target run() method will run.
Thread Schedular in java :
Thread schedular is the part of the JVM that decides which thread should run first .There is no guarantee that which runnable thread will be chosen to run by the thread scheduler.
Only one thread at a time can run in a single process.The thread scheduler mainly uses preemptive or time slicing scheduling to schedule the threads.
Java/j2ee classes bangalore
Author :
Infocampus is a java training center bangalore with the 100% placement assistance. It provides java course with the live project. Complete practical session is available for Core and Advance Java . 4 days free demo classes are provided for java/j2ee classes.
Training is given by the 10+ years experienced trainers .Learn packages, Threading,OOPs concept,servlet,spring ,hibernate etc in best core java training institute.
To get the free demo classes call at : 9738001024 or for the more details on Advance java training visit at : http://www.infocampus.co.in/java-training-bangalore.html

Total Views: 474Word Count: 590See All articles From Author

Add Comment

Computer Programming Articles

1. Which Institute Is Best For Coding And Programming In Bhopal?
Author: Shankar Singh

2. Top 9 Benefits Of Custom Mobile Application Development
Author: Byteahead

3. Top 10 Creative Business Ideas For Entrepreneurs
Author: Byteahead

4. Top 10 Apps Like Tiktok Everyone Should Check Out
Author: Byteahead

5. Is The Apple Watch Series 7 Worth It For Seniors?
Author: Ashish

6. The Ultimate Guide To Ebay Product Listing Services: Elevate Your Online Store
Author: rachelvandereg

7. Which Are The Best Java Coding Classes In Bhopal?
Author: Shankar Singh

8. Warehouse Management In Zambia: Essential Features To Look For
Author: Doris Rose

9. Ecommerce Web Design And Development In Melbourne With The Merchant Buddy
Author: themerchantbuddy

10. Why Website Maintenance Is Crucial For Business Success
Author: Yogendra Shinde

11. Boost Your Business With Smart Invoice Pos Software In Zambia
Author: Cecilia Robert

12. How Stablecoin Development Ensures Stability And Security?
Author: Michael noah

13. Công Cụ Tính Chiều Cao Chuẩn Từ Minbin Tool: Đo Lường Và Cải Thiện Chiều Cao Hiệu Quả
Author: KenJi123

14. How To Make A Courier App For Courier Delivery And Tracking Service
Author: Deorwine Infotech

15. Reputation Management In The Digital Age: Protecting And Enhancing Your Law Firm’s Image
Author: jamewilliams

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: