src/share/classes/com/sun/corba/se/impl/orbutil/threadpool/WorkQueueImpl.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 109,136 **** // class MonitoredObject getMonitoredObject() { return workqueueMonitoredObject; } ! public void addWork(Work work) { ! synchronized (this) { workItemsAdded++; work.setEnqueueTime(System.currentTimeMillis()); theWorkQueue.addLast(work); ((ThreadPoolImpl)workerThreadPool).notifyForAvailableWork(this); } - } ! Work requestWork(long waitTime) ! throws TimeoutException, InterruptedException { Work workItem; ! synchronized (this) { if (theWorkQueue.size() != 0) { workItem = (Work)theWorkQueue.removeFirst(); totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime(); workItemsDequeued++; return workItem; } try { --- 109,135 ---- // class MonitoredObject getMonitoredObject() { return workqueueMonitoredObject; } ! public synchronized void addWork(Work work) { workItemsAdded++; work.setEnqueueTime(System.currentTimeMillis()); theWorkQueue.addLast(work); ((ThreadPoolImpl)workerThreadPool).notifyForAvailableWork(this); } ! synchronized Work requestWork(long waitTime) throws TimeoutException, InterruptedException { Work workItem; ! ((ThreadPoolImpl)workerThreadPool).incrementNumberOfAvailableThreads(); ! if (theWorkQueue.size() != 0) { workItem = (Work)theWorkQueue.removeFirst(); totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime(); workItemsDequeued++; + ((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads(); return workItem; } try {
*** 143,166 **** if (theWorkQueue.size() != 0) { workItem = (Work)theWorkQueue.removeFirst(); totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime(); workItemsDequeued++; return workItem; } remainingWaitTime = finishTime - System.currentTimeMillis(); } while (remainingWaitTime > 0); throw new TimeoutException(); } catch (InterruptedException ie) { throw ie; } } - } public void setThreadPool(ThreadPool workerThreadPool) { this.workerThreadPool = workerThreadPool; } --- 142,167 ---- if (theWorkQueue.size() != 0) { workItem = (Work)theWorkQueue.removeFirst(); totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime(); workItemsDequeued++; + ((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads(); return workItem; } remainingWaitTime = finishTime - System.currentTimeMillis(); } while (remainingWaitTime > 0); + ((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads(); throw new TimeoutException(); } catch (InterruptedException ie) { + ((ThreadPoolImpl)workerThreadPool).decrementNumberOfAvailableThreads(); throw ie; } } public void setThreadPool(ThreadPool workerThreadPool) { this.workerThreadPool = workerThreadPool; }