Threads on runnable interface

Threads on runnable interface

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 - 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... methods too. After creating class that implements Runnable interface, you can...Java : Runnable Thread In this tutorial we are describing Runnable Thread
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
Creation of Multiple Threads
interface Runnable. Lets see an example having the implementation... interface: class MyThread1 implements Runnable{   Thread t;   MyThread1.... It means, you can use either class Thread or interface Runnable to implement thread
interface
interface   what is the use of marking interface
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
Java Thread and Runnable
Java Thread and Runnable  What's the difference between Thread and Runnable types
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
INTERFACE
INTERFACE  how interface support multiple inheritance in java
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  can we extend interface?   Hi Friend, Yes an interface can be extended by other interface like using extends keyword interface A{ } interface B extends A{ } For Example: interface IntefaceA { void
interface
interface  what the use of interface?   An interface is one... variables.Any class can implement(inherit)the interface and make use... is achieved by using the interface (by implementing more than one interface at a time
interface
interface  What is marker interface ?? what is its use in java programming?? is this us in programming ??Explain is implementation with code
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
interface
interface  develop a library interface which has drawbook(),returnbook()(with fine),checkstatus() and reservebook() methods.all the methods tagged with public
Interface
for Interface in java? and want to know why they used interface instead of multiple inheritance? Thanks in advance   An interface is one which has abstract... implement(inherit)the interface and make use of the methods(functions
interface
interface  why do we need interface in java..if it`s usefull for to obtain multiple inheritance in the sense how it gonna be achieved...and i can...)...the y we need interface...THis is question often i heard from my developer
Interface
Interface  I need to implement the interface without overriding its method and also don't use abstract class for this. How to do
interface
interface  What is the exact use of interface in real time scenario? some people says that interface provides multiple inheritance. Is it true...; Through interface, we can achieve the multiple inheritance. Java does
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
Interface
Interface  1.Create an interface names ShapeInterface that has two... class a.Rectangle that uses the interface b.Circle that uses the interface and abstract class   interface ShapeInterface{ int l=0,b=0; public
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
Interface
Interface  Declare an Interface called property containting a method compute price to compute &return the price.The inerface is to be implemented by follwaing two class (1)Bungalow&(2)Flat both the lasses have following
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
threads and events
threads and events  Can you explain threads and events in java for me. Thank you.   Java Event Handling Java Thread Examples
Java threads
Java threads  What are the two basic ways in which classes that can be run as threads may be defined
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
disadvantage of threads
is the disadvantage of threads?   hello,ADS_TO_REPLACE_1 The Main disadvantage of in threads these are operating system dependent.   Hi, Here... the disadvantages of threads. The global variables defined in the application is not thread
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
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
threads
threads
Threads
ModuleNotFoundError: No module named 'nose_runnable_test_names'
ModuleNotFoundError: No module named 'nose_runnable_test_names'  Hi...: No module named 'nose_runnable_test_names' How to remove the ModuleNotFoundError: No module named 'nose_runnable_test_names' error? Thanks  
ModuleNotFoundError: No module named 'nose_runnable_test_names'
ModuleNotFoundError: No module named 'nose_runnable_test_names'  Hi...: No module named 'nose_runnable_test_names' How to remove the ModuleNotFoundError: No module named 'nose_runnable_test_names' error? Thanks  
ModuleNotFoundError: No module named 'nose_runnable_test_names'
ModuleNotFoundError: No module named 'nose_runnable_test_names'  Hi...: No module named 'nose_runnable_test_names' How to remove the ModuleNotFoundError: No module named 'nose_runnable_test_names' error? Thanks  
ModuleNotFoundError: No module named 'runnable-pkg-cef'
ModuleNotFoundError: No module named 'runnable-pkg-cef'  Hi, My... named 'runnable-pkg-cef' How to remove the ModuleNotFoundError: No module named 'runnable-pkg-cef' error? Thanks   Hi, In your

Ads