FileDocCategorySizeDatePackage
Account_Impl_LockThread.javaAPI DocExample1247Thu Nov 08 00:22:52 GMT 2001com.ora.rmibook.chapter15.bank

Account_Impl_LockThread

public class Account_Impl_LockThread extends Thread

Fields Summary
private static final int
THREAD_SLEEP_TIME
private static Account_Impl_LockThread
_singleton
private ArrayList
_accounts
Constructors Summary
private Account_Impl_LockThread()

        _accounts = new ArrayList();
    
Methods Summary
public synchronized voidaddAccount(Account newAccount)

        _accounts.add(newAccount);
    
private synchronized voiddecrementLockTimers()

        Iterator i = _accounts.iterator();

        while (i.hasNext()) {
            Account_Impl nextAccount = (Account_Impl) i.next();

            nextAccount.decrementLockTimer(THREAD_SLEEP_TIME);
        }
    
public static synchronized com.ora.rmibook.chapter15.bank.Account_Impl_LockThreadgetSingleton()


         
        if (null == _singleton) {
            _singleton = new Account_Impl_LockThread();
            _singleton.start();
        }
        return _singleton;
    
public voidrun()

        while (true) {
            try {
                Thread.sleep(THREAD_SLEEP_TIME);
            } catch (Exception ignored) {
            }
            decrementLockTimers();
        }