Computer Science, asked by sivanichowdaryuppala, 2 months ago

1.
Write a Java Program to create two threads and
implement all methods available in thread class.​

Answers

Answered by jayveertanwar13
1

Answer:

package com.company;

class Practice13 extends Thread{

public void run(){

while(true){

System.out.println("Good Morning!");

}

}

}

class Practice13b extends Thread{

public void run(){

// while(false){

// try {

// Thread.sleep(200);

// }

// catch (Exception e){

// System.out.println(e);

// }

// System.out.println("Welcome");

// }

}

}

public class cwh_76_practice13 {

public static void main(String[] args) {

Practice13 p1 = new Practice13();

Practice13b p2 = new Practice13b();

// p1.setPriority(6);

// p2.setPriority(9);

System.out.println(p1.getPriority());

System.out.println(p2.getPriority());

System.out.println(p2.getState());

// p1.start();

p2.start();

System.out.println(p2.getState());

System.out.println(Thread.currentThread().getState());

}

}

use intellij idea to use this cose.

Similar questions