Java Runnable.run()

Syntax

Runnable.run() has the following syntax.

void run()

Example

In the following code shows how to use Runnable.run() method.


//from  ww  w.j  a  va2 s  .  c  o  m
class caller implements Runnable {
  String msg;


  public caller(String s) {
    msg = s;
    new Thread(this).start();
  }

  public void run() {
    System.out.println("run");
  }
}

public class Main {
  public static void main(String args[]) {
    new caller("Hello");
  }
}
     

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable