Java
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override public void run() {
// Code to execute on a thread. For example, print the text:
System.out.println("I am eating");
}
});
Java
Runnable myRunnable = new Runnable() {
public void run(){
// Code to execute on a thread. For example, print the text:
System.out.println("I am eating");
}
};
Thread thread = new Thread(myRunnable);
thread.start();
Java
Creating a new Java console application ... and write the code
import java.util.concurrent.Executors;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println("Hello!");
// create thread
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override public void run() {
System.out.println("I am eating");
}
});
// wait symbol main thread is working
System.in.read();
}
}