My Blog
Articles related to programming, computer science, technology and research.

Java program for life cycle of a thread

08/06/2016 Categories: Threads. Comments Off on Java program for life cycle of a thread

Java program to demonstrate life cycle of a thread. import java.util.*; class ChildThread implements Runnable { Thread t; ChildThread() { t = new Thread(this); System.out.println(“Thread is in new state”); t.start(); } public void run() { System.out.println(“Thread is in runnable state”); Scanner s = new Scanner(System.in); System.out.println(“Thread entering blocked state”); System.out.print(“Enter a string: “); String str […]

Read the rest of this entry »

Java program that creates three threads

08/06/2016 Categories: Threads. Comments Off on Java program that creates three threads

Java program that creates three threads. First thread displays “Good Morning” every one second, the second thread displays “Hello” every two seconds and the third thread displays “Welcome” every three seconds.

Output for the above program is as follows: First Thread: Good Morning Second Thread: Hello First Thread: Good Morning Third Thread: Welcome First […]

Read the rest of this entry »
Scroll Up