Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java MultiThread

Have Programming Question? Ask it here!
 
 
 


bandhi lingamurthy
Java MultiThread
1 Answer(s)      5 years and 11 months ago
Posted in : Java Beginners



Advertisement
View Answers

September 11, 2008 at 11:15 AM


Hi friend,


A program or process can contain multiple threads that execute instructions according to program code. Like multiple processes that can run on one computer, multiple threads appear to be doing their work in parallel. Implemented on a multi-processor machine, they actually can work in parallel.


Here is the code.


class ThreadTest implements Runnable {
Thread test;
ThreadTest(){
test = new Thread(this, "Demo Thread");
System.out.println("Child Thread:" + test);
test.start();

}

public void run() {
try {
for(int i = 5; i > 0; i--) {
System.out.println("Display Child Thread:" + i);
Thread.sleep(500);
}
}
catch (InterruptedException e) {
System.out.println("Child Interrupted");
}
System.out.println("Exiting Child Thread.");
}
}
public class ThreadDemo {
public static void main(String args[]){

new ThreadTest();
try {
for(int i = 5; i > 0; i--){

System.out.println("Display Main Thread:" + i);
Thread.sleep(1000);
}
}
catch (InterruptedException e) {
System.out.println("Main Thread Interrupted" + e);
}
System.out.println("Exiting Main Thread.");
}
}

-----------------------------------------------------

Visit for more information.

http://www.roseindia.net/java/thread/Java-Multithreading.shtml

Thanks.



Related Tutorials/Questions & Answers:
Java Multithread
Java Multithread  Hi All. I am trying to make a program in Java that uses Multithread. That program is about a bank account shared between husband and wife who use debit cards. I wrote the Java program using 2 threads but i am
Java MultiThread - Java Beginners
Java MultiThread  what is the meaning of standalone application in multithread.How can we write multi programms in multithread process and execution...."); } } ----------------------------------------------------- Visit for more information. http://www.roseindia.net/java/thread/Java
Advertisements
java multithread - Java Beginners
java multithread  Hi, I have developed one java application.It should be running continuously. Using multithreads how to make the application to run continuously. Could you please help me. Thank you,  Hi Friend
java multithread - Java Beginners
java multithread  Hi, Thanks for your multithreading java code. It helped me a lot. But i have one issue. My code is look like this. public class classname extends Thread { public classname() { super
java multithread - Development process
java multithread  sir i am send it again sir.please reply me sir.Develop multi-threaded echo server and a corresponding GUI client in java.  Multi-threaded ECHO SERVER and GUI client program by Whitman Kumaresh for my
Java MultiThread
Java has multithreading feature. Multithreading feature is given by Thread class and Runnable interface Java Multithreading allows to run multiple tasks(threads) at a time. Java Multi Thread Example public class multi
Multithreading ? - Java Interview Questions
Multithreading ?   Hi Friends, I am new to java , am not clear with Multithreading. Multithread will cause deadlock. We can... program. For read more information on Multithread visit to : http
Java Interview Questions - Page 5
Java Interview Questions - Page 5       Question: How to create multithread in a program... to start the thread. Question: Can Java object be locked down for exclusive
Java Exception - Handle Exceptions in Java
Java Exception - Handle Exceptions in Java       What is Exception in Java? How to handle the Exceptions in Java programming language. This section on exception
Java Exception Thread
Java Exception Thread     ... the program. Many Thread run concurrently in the program. Multithread are those...,the thread run concurently,synchronous or asynchronous. Advantage of Multithread
java
java  diff bt core java and java
java
java  what is java
Java
Java   Whether Java is pure object oriented Language
JAVA
JAVA  how the name came for java language as "JAVA
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java   difference between class and interface
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  why to set classpath in java
java
java  Does java allows multiline comments
java
java  sample code for RARP using java
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java  why multiple inheritance is not possible in java
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  RARP implementation using java socket
java
java   What is ?static? keyword
java
java  how can use sleep in java   which book learn of java language
java
java  different between java & core java print("code sample
java
java  different between java & core java print("code sample
java
java  how to edit text document by using java then how to edit starting and ending of text document by using java
java
java online telephone directory  i need coding for online telephone directory..by using java....pls help me
java
java code to search the nodes  how to write the java code to search the nodes using routers
 

 

 

DMCA.com