-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain56.java
70 lines (69 loc) · 1.46 KB
/
Main56.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main;
import lab5.*;
import java.util.Scanner;
public class Main56
{
public static void prime() throws Exception
{
new Prime(100,200);
}
public static void incre()
{
try
{
new Incr();
}
catch(Exception e)
{
System.out.println("caught");
}
}
public static void HiLopri()
{
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
clicker hi=new clicker(Thread.NORM_PRIORITY +2);
clicker lo=new clicker(Thread.NORM_PRIORITY -2);
lo.start();
hi.start();
try
{
Thread.sleep(10000);
}
catch(InterruptedException e)
{
System.out.println("Main thread interrupted.");
}
lo.stop();
hi.stop();
try
{
hi.t.join();
lo.t.join();
}
catch(InterruptedException e)
{
System.out.println("interruptedException caught");
}
System.out.println("Low-priority thread:"+lo.click);
System.out.println("High-priority thread:"+hi.click);
}
public static void main(String a[]) throws Exception
{
int ch;
Scanner ob=new Scanner(System.in);
System.out.println("\n1.Find Prime\n2.Increment variable\n3.set Queue priority\n");
System.out.println("Enter your choice: ");
ch = ob.nextInt();
switch(ch)
{
case 1:prime();
break;
case 2:incre();
break;
case 3:HiLopri();
break;
default:
System.out.println("enter a valid choice");
}
}
}