Thread printThread new Thread new Runnable Override public void run fo

 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
Thread printThread = new Thread(new Runnable() {
@Override
public void run() {
for (; ; ) {
try {
currencyCollection.printCurrencyCollections();
Thread.sleep(1000);
System.out.println("1");
Thread.sleep(1000);
System.out.println("2");
Thread.sleep(1000);
System.out.println("3");
Thread.sleep(1000);
System.out.println("4");
Thread.sleep(1000);
System.out.println("5");
Thread.sleep(1000);
System.out.println("6");
Thread.sleep(1000);
System.out.println("7");
Thread.sleep(1000);
System.out.println("8");
} catch (InterruptedException e) {
e.printStackTrace();
}
if (currencyCollection.getFinish()) {
break;
}
}
}
});