-
Notifications
You must be signed in to change notification settings - Fork 1
/
BogdanThread.java
34 lines (30 loc) · 904 Bytes
/
BogdanThread.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
import java.util.logging.Level;
import java.util.logging.Logger;
import java.net.*;
public class BogdanThread extends Thread
{
private Bogdan bogdan;
BogdanThread( Bogdan obj )
{
bogdan = obj;
}
public void run()
{
//While other parts of the program want the thread to, this changes the
// images of Bogdan sleeping (flipping between the two) every x
// millseconds. x is deturmined by bogdan.getSleepingWait().
while ( bogdan.keepSleeping() && !bogdan.getStopForCleaner() )
{
bogdan.changeSleepingImage();
pause( bogdan.getSleepingWait() );
}
}
private void pause ( int time )
{
try {
Thread.sleep(time);
} catch (InterruptedException ex) {
Logger.getLogger(BogdanThread.class.getName()).log(Level.SEVERE, null, ex);
}
}
}