// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class CreateThreadWays {
    public static class MyThread extends Thread {
        @Override
        public void run() {
            System.out.println("MyThread: " + Thread.currentThread().getId());
        }
    }
    public static class MyRunnable implements Runnable {
        @Override
        public void run() {
            System.out.println("MyRunnable: " + Thread.currentThread().getId());
        }
    }
    public static void main(String[] args) throws InterruptedException {
        System.out.println("main: " + Thread.currentThread().getId());
        Thread t1 = new MyThread();
        t1.start();
        t1.join();
        Thread t2 = new Thread(new MyRunnable());
        t2.start();
        t2.join();
        Thread t3 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("anonymous Runnable: " + Thread.currentThread().getId());
            }
        });
        t3.start();
        t3.join();
        Thread t4 = new Thread(() -> {
            System.out.println("lambda: " + Thread.currentThread().getId());
        });
        t4.start();
        t4.join();
    }
}
