import java util concurrent Created with IntelliJ IDEA User dmytro zay

 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.concurrent.*;
/**
* Created with IntelliJ IDEA.
* User: dmytro.zaytsev
* Date: 4/1/14
* Time: 11:43 PM
* To change this template use File | Settings | File Templates.
*/
import java.util.concurrent.ExecutorService;
public class NewOperations {
static ExecutorService executorService = Executors.newFixedThreadPool(3);
// static ExecutorService scheduler = ;
public static void main(String[] args) {
final BankAccount first = new BankAccount(10000,1);
BankAccount second = new BankAccount(100, 2);
Executors.newScheduledThreadPool(1).schedule(new Runnable() {
@Override
public void run() {
System.out.println("<<<First account withdrawals = " + first.getAcceses());
}
},1000,TimeUnit.MILLISECONDS) ;
for(int i = 0; i < 20; i++) {
executorService.submit(new Transaction(first, second, 1000,i));
}
executorService.shutdown();
System.out.println(first.currentBalance);
System.out.println(first.getAcceses());
}
}