Skip to content

Instantly share code, notes, and snippets.

@AnjaliManhas
Created July 27, 2020 14:45
Show Gist options
  • Save AnjaliManhas/7f0febb9905e5bd1a53cd86001677212 to your computer and use it in GitHub Desktop.
Save AnjaliManhas/7f0febb9905e5bd1a53cd86001677212 to your computer and use it in GitHub Desktop.
package com.wordpress.compilationerrors;
import java.lang.Thread;
class MultithreadingDemo extends Thread {
public void run(){
try {
System.out.println("Thread"+ Thread.currentThread().getId()+" is running");
}
catch(Exception e){
System.out.println("Exception is caught");
}
}
}
public class Main {
public static void main(String[] args) {
// write your code here
int n = 8; //no. of threads
for(int i = 0; i < n; i++){
MultithreadingDemo obj = new MultithreadingDemo();
obj.start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment