Example HTML page

java assignment 5

Hi, Please do the following assignment work.

1.Create a thread as a class ‘MyThread’ and by using one of the way to create a thread this class should extend the root ‘Thread’ class. Also demonstrate the run( ) method which is used for entry point of a new thread as well as the usage of start ( ) which in turn calls the run( ) for executing a thread.

2.Create a thread as a class ‘MyThread’ and by using one of the way to create a thread this class should implement the “Runnable” interface. Also demonstrate the run( ) method which is used for entry point of a new thread as well as the usage of start ( ) which in turn calls the run( ) for executing a thread.

3.Create a Thread class ‘MyThreadAlive’ extending from the ‘Thread’ class. create 2 threads t1 & t2. By the concept of MultiThreading, show how both the threads are going to be executed simultaneously with the help of isAlive( ). For parallel execution you should use the sleep( ) which will suspend the particular thread for some amount of time, meanwhile the other thread can execute concurrently.

4.Demonstrate without allowing parallel execution the  2 threads t1 & t2 should execute one by one it means after the completion of first thread execution then the other should join.(Hint: use join( ) to join the thread).

5.Apply the concept of synchronization which uses the shared resource among multiple threads. Implement the synchronised block to display the output as “[welcome] [java] [programmer]”.

6.Apply the concept of Deadlock in which multiple threads are entering into loop holding some resources and still requesting for other resources. Create 2 threads t1 & t2. let us suppose t1 is holding resource as “pen” and requesting for  other resource “paper”, similarly t2 is holding “paper” and requesting for “pen” that shows this condition leads to the occurence of deadlock.

Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest