-
Notifications
You must be signed in to change notification settings - Fork 0
/
IconProducer.java
43 lines (36 loc) · 1.05 KB
/
IconProducer.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
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Sudoku;
import java.util.Random;
import javax.swing.Icon;
/**
*
* @author Oreoluwa
*/
public class IconProducer implements Runnable{
private Random generator = new Random();
private BlockingIcon sharedLocation;
private Icon[] logos;
public boolean isDone = false;
public IconProducer(BlockingIcon shared, Icon[] images){
sharedLocation = shared;
logos = images;
}
@Override
public void run() {
try{
for(int i =0; i<=logos.length && !isDone ; i++){
int sleepTime = generator.nextInt(3000);//sleeps for 3secs
Thread.sleep(sleepTime);
sharedLocation.set(logos[i]);
if(i==(logos.length-1)){
i=0;//so that i doesnt reach the end. i.e a continuous loop
}
}
}catch(InterruptedException ex){
ex.printStackTrace();
}
}
}