Yes, you can call the run method of a Thread Class Directly. But when you call ‘run’ method directly, it executes like a normal method execution.
Application.java
package com.sample.app;
public class Application {
private static Thread thread = new Thread() {
public void run() {
System.out.println("Hello World");
}
};
public static void main(String args[]) {
thread.run();
thread.run();
}
}
Output
Hello World
Hello World
You may like
Interview Questions
Programming Questions
Miscellaneous
Static and Dynamic class loading
Different ways to dynamically load a class
Class.forName vs ClassLoader.loadClass
How the jdbc driver is loaded?
Can I overload main method of a class?
Can I throw an exception from static block?
Does yield method releases the lock?
This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here