Computer Science, asked by samksqjsj233, 4 months ago

Write a java code
Create two threads and assign names ‘Scooby’ and ‘Shaggy’ to the two threads. Display both thread names.

Answers

Answered by saver629
2

public class Assignment1 {

public static void main(String[] args) {

Thread t1 = new Thread("Scooby") {

public void run() {

System.out.println("I'm " + Thread.currentThread().getName());

}

};

Thread t2 = new Thread("Shaggy") {

public void run() {

System.out.println("I'm " + Thread.currentThread().getName());

}

};

t1.start();

t2.start();

}

}

Similar questions