Last active
July 11, 2021 09:52
-
-
Save wkdalsgh192/958e206a282cdb6e6a9b1b9aca0cb905 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. create a sub class inherent to Thread class | |
static class MyThread extends Thread { | |
@Override | |
public void run() { | |
System.out.println("Hello : "+Thread.currentThread().getName()); | |
} | |
} | |
MyThread myThread = new MyThread(); | |
myThread.start(); | |
// 2. implement Runnable | |
Thread thread = new Thread(new Runnable() { | |
@Override | |
public void run() { | |
System.out.println("Hello : "+ Thread.currentThread().getName()); | |
} | |
}); | |
// 2-1 implement Runnable in functional programming | |
Thread thread = new Thread(() -> System.out.println("Hello : "+ Thread.currentThread().getName())); | |
thread.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment