-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththrd.java
More file actions
41 lines (34 loc) · 1 KB
/
thrd.java
File metadata and controls
41 lines (34 loc) · 1 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package exponn;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Suleman
*/
public class thrd implements Runnable {
Random r = new Random();
String n;
int time;//= r.nextInt(999);
static boolean d = false;
public thrd(String name, double t) {
n = name;
time = (int) (t * 10);
// System.out.println("in thread time "+time);
}
public void run() {
System.out.println(n + " thread is running for " + time);
try {
Thread.sleep(time / 10);
} catch (InterruptedException ex) {
Logger.getLogger(thrd.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(n + " thread is done");
d=true;
}
}