public class priority implements Runnable {
@Override
public void run() {
for (int x = 1; x <= 3; x++)
System.out.println(x + " This is thread "
+ Thread.currentThread().getName());
}
public static void main(String[] args) {
Thread t1 = new Thread(new priority(), "Thread A");
Thread t2 = new Thread(new priority(), "Thread B");
Thread t3 = new Thread(new priority(), "Thread C");
t1.setPriority(10);
t1.start();
t2.start();
t3.start();
}
}
Output
1 This is thread Thread A 2 This is thread Thread A 3 This is thread Thread A 1 This is thread Thread C 1 This is thread Thread B 2 This is thread Thread C 3 This is thread Thread C 2 This is thread Thread B 3 This is thread Thread BIf you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.