Skip to content

Instantly share code, notes, and snippets.

@h-hub
Last active November 2, 2021 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save h-hub/dab072fc8861596fc5b67c39a517a51e to your computer and use it in GitHub Desktop.
Save h-hub/dab072fc8861596fc5b67c39a517a51e to your computer and use it in GitHub Desktop.
main.java
public class Main {
public static void main(String[] args) {
Thread thread1 = new Thread(new HelloRunnable());
thread1.start();
Thread thread2 = new Thread(new HelloThread());
thread2.start();
}
//Provide a Runnable object
static class HelloRunnable implements Runnable {
public void run() {
System.out.println("Hello(Runnable) from a thread!");
}
}
//Subclass Thread
static class HelloThread extends Thread {
public void run() {
System.out.println("Hello(Thread) from a thread!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment