шпаргалки
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
996 B

2 years ago
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package multithreadingexample;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author denis
*/
public class BankOperation implements Runnable{
@Override
public void run() {
BankAccount account = Bank.accounts.get(0);
synchronized (account){
String line = "Состояние до: " + account.getFund() + "руб., добавляем 10000 и получаем: " + account.fundUp(10000);
System.out.println(line);
}
synchronized (account){
String line = "Состояние до: " + account.getFund() + "руб., убавляем на 10000 и получаем: " + account.fundDown(10000);
System.out.println(line);
}
}
}