FileDocCategorySizeDatePackage
Account3_Impl2_LockThread.javaAPI DocExample1263Thu Nov 08 00:22:34 GMT 2001com.ora.rmibook.chapter12.bank

Account3_Impl2_LockThread

public class Account3_Impl2_LockThread extends Thread

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

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

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

        Iterator i = _accounts.iterator();

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

            nextAccount.decrementLockTimer(THREAD_SLEEP_TIME);
        }
    
public static synchronized com.ora.rmibook.chapter12.bank.Account3_Impl2_LockThreadgetSingleton()


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

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