/* * 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); } } }