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



Home Answers Viewqa Java-Beginners Threads on runnable interface
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


manshi
Threads on runnable interface
1 Answer(s)      6 years and 7 months ago
Posted in : Java Beginners



Advertisement
View Answers

May 31, 2008 at 4:55 PM


Hi

class MyThread extends Thread{
MyThread(String s){
super(s);
start();
}
public void run(){
System.out.println("Thread Name :"+Thread.currentThread().getName());
try{
Thread.sleep(1000);
}catch(Exception e){
System.out.println(e);
}
}
}
public class Thread1{
public static void main(String args[]){
System.out.println("Thread Name :" +Thread.currentThread().getName());
MyThread m1=new MyThread("Hello");
MyThread m2=new MyThread("Welcome");
}
}

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

Read for more information.

http://www.roseindia.net/java/thread/thread-creation.shtml



Related Tutorials/Questions & Answers:
Threads on runnable interface - Java Beginners
Threads on runnable interface  need a program.....please reply asap Create 2 threads using runnable interface.First threads shd print "hello" & second shd print "welcome". using synchronisation tech print d words alternatively
Threads on runnable interface - Java Beginners
Threads on runnable interface  need a program.....please reply asap Create 2 threads using runnable interface.First threads shd print "hello" & second shd print "welcome". using synchronisation tech print d words alternatively
Advertisements
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... inheritance feature whereas If you implement runnable interface, you can gain better
Diff between Runnable Interface and Thread class while using threads
Diff between Runnable Interface and Thread class while using threads  Diff between Runnable Interface and Thread class while using threads  ... inheritance feature whereas If you implement runnable interface, you can gain better
Java Runnable Interface
Java Runnable Thread is a piece of the program execution. Java Runnable is an interface. Thread class implements it. Java has multithreading facility. Thread is also created by implementing the Runnable interface. Java
Runnable interface in java
In this section we will learn about Runnable interface in java. In java thread are created by two ways, one by extending Thread class and another one by implementing Runnable interface
Difference between extends thread class vs implements runnable interface - Java Interview Questions
and implementing runnable interface.  Hi Friend, Difference: 1)If you... runnable interface, you can gain better object-oriented design and consistency... will give you simple code structure in comparison to Runnable Interface. 3)Using
Threads
Threads  Extends Thread or Implementing Runnable Interface...; Runnable is better solution because of the following reasons: 1)Leaves more flexibility for the Runnable implementation to extend another class. 2
threads
threads  what are threads? what is the use in progarmming
Threads
Threads   class Extender extends Thread { Extender(Runnable run){ super(run); super.start(); //this.start...(); } } class Implementer implements Runnable { public void run
Threads
Threads   class Extender extends Thread { Extender(Runnable run){ super(run); super.start(); //this.start...; }<br> } class Implementer implements Runnable { public void run
Runnable JAR
Runnable JAR  How to create runnable JAR file in eclipse ? Please provide me step by step demo... I am windows 7 user. I have made one jar file but when I double click it,it doesn't run. Why so
Runnable JAR
Runnable JAR  How to create runnable JAR file in eclipse ? Please provide me step by step demo... I am windows 7 user. I have made one jar file but when I double click it,it doesn't run. Why so
runnable - Java Beginners
runnable  is java.lang.Runnable is marker interface?  Hi Friend, We all know that marker interface does not contain any method. But Runnable is a marker interface even though it is having run() method. Thanks
Java : Runnable Thread
a thread by implementing the Runnable interface. You need to implement a single.... After creating class that implements Runnable interface, you can create object... by using Runnable interface. class RunnableThread implements Runnable
Creation of Multiple Threads
interface Runnable. Lets see an example having the implementation... create the same program implenting the Runnable interface: class MyThread1... Thread or interface Runnable to implement thread in your program. Download
Java Thread and Runnable
Java Thread and Runnable  What's the difference between Thread and Runnable types
Threads - Java Interview Questions
feature whereas If you implement runnable interface, you can gain better object... to Runnable Interface. 3)Using Runnable Interface, you can run the class several... and implements runnabule interface. What is the diffrence between those two?which
threads and events
threads and events  Can you explain threads and events in java for me. Thank you.   Java Event Handling Java Thread Examples
threads in java
threads in java  how to read a file in java , split it and write into two different files using threads such that thread is running twice
multi threads - Java Beginners
using three threads. I want to declare variables which will be available to all the threads to access. Is there a way to declare the variables as global variables which will be available to all the threads. If so please send me the code
Java threads
Java threads  What are the two basic ways in which classes that can be run as threads may be defined
interface
interface   what is the use of marking interface
disadvantage of threads
is the disadvantage of threads?   hello, The Main disadvantage of in threads... disadvantage of Threads. Let?s discuss the disadvantages of threads. The global..., the other threads using the same memory location will be killed automatically
interface.
interface.  Write short note on interface.   Please visit the following link: Java Interface
interface
interface  will the interface implements a interface   Hi Friend, No. Interface can extends another interface but cannot implements it, because interface will not contain the implementation. Thanks
Sync Threads
Sync Threads  "If two threads wants to execute a synchronized method in a class, and both threads are using the same instance of the class to invoke the method then only one thread can execute the method at a time." This is what
To make java exe or runnable file
To make java exe or runnable file   Helo sir i make a java application.I need to help how run application direct in pc i.e how it packaged, .exe file or setup file
threads in java
threads in java  iam getting that the local variable is never read in eclipse in main classas:: class Synex4{ public static void main(String args[]){ Test1 ob1=new Test1(); //local variable never read
interface
interface   Hi I have interface in that interface 3 methods are there , after some days client said that,i want to add one more method in that interface ,so how can add 4 method so that the implemented class did not affect
INTERFACE
INTERFACE  how interface support multiple inheritance in java
Advertisements
 

 

 

DMCA.com