A)
->to make java applications multithreaded, java language support available through 2 modifiers.
1) volatile
2) synchronized
API support (i.e. library support) is also available through a library class and an interface.
1) java.lang.Thread ( Thread is a class)
2) java.lang.Runnable ( Runnable is a interface)
Steps to develop a multithreaded application:
Step 1:
Find out how many concurrent tasks that application may have to perform ( i.e. how many flows is there in our program i.e. analyzing in first step).
Step 2:
Define a user class that extends java.lang.Thread class or implements java.lang.Runnable interface.
Define a user class that extends java.lang.Thread class or implements java.lang.Runnable interface.
Step 3:
Override run () method and place task performing code in that method directly or indirectly.
Step 4:
Create as no. of Thread objects of required either instantiating java.lang.Thread class or its user defined sub class.
Create as no. of Thread objects of required either instantiating java.lang.Thread class or its user defined sub class.
Step 5:
Activate the Threads.
Activate the Threads.
Comments
Post a Comment