-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram10.java
More file actions
34 lines (30 loc) · 777 Bytes
/
Copy pathProgram10.java
File metadata and controls
34 lines (30 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//WAP that creates three threads which print no.s from 1 to 5, 6 to 10 and 11 to 15 respectively .Set the name & priority of the threads.
package com.mycompany.program10;
class MyThread01 extends Thread {
int n, m;
MyThread01(int n, int m) {
this.n = n;
this.m = m;
}
public void run() {
for (int i = n; i <= m; i++) {
System.out.println(i);
}
}
}
public class Program10 {
public static void main(String[] args) {
MyThread01 a = new MyThread01(1, 5);
MyThread01 b = new MyThread01(6, 10);
MyThread01 c = new MyThread01(11, 15);
a.setName("Thread01");
b.setName("Thread02");
c.setName("Thread03");
a.setPriority(Thread.MAX_PRIORITY);
b.setPriority(Thread.NORM_PRIORITY);
c.setPriority(Thread.MIN_PRIORITY);
c.start();
a.start();
b.start();
}
}