Created
July 27, 2020 14:45
-
-
Save AnjaliManhas/7f0febb9905e5bd1a53cd86001677212 to your computer and use it in GitHub Desktop.
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
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