Last active
November 2, 2021 05:21
-
-
Save h-hub/dab072fc8861596fc5b67c39a517a51e to your computer and use it in GitHub Desktop.
main.java
This file contains 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
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