forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetTheMail.java
More file actions
33 lines (26 loc) · 743 Bytes
/
GetTheMail.java
File metadata and controls
33 lines (26 loc) · 743 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
// You can use the Runnable interface instead of
// wasting your 1 class extension.
public class GetTheMail implements Runnable {
// Stores the number of seconds before the code
// will be executed
private int startTime;
// Constructor that sets the wait time for each
// new Thread
public GetTheMail(int startTime){
this.startTime = startTime;
}
// All of the code that the thread executes must be
// in the run method, or be in a method called for
// from inside of the run method
public void run(){
try
{
// Don't execute until 10 seconds has passed if
// startTime equals 10
Thread.sleep(startTime * 1000);
}
catch(InterruptedException e)
{}
System.out.println("Checking for Mail");
}
}