/** Closes the pool. */ public synchronized void shutdown() { while (!waitingThreads.isEmpty()) { Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1); poolable.shutdown(); } while (!runningThreads.isEmpty()) { Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1); poolable.shutdown(); } }
/** Closes the pool. */ public synchronized void shutdown() { while (!waitingThreads.isEmpty()) { Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1); poolable.shutdown(); } while (!runningThreads.isEmpty()) { Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1); poolable.shutdown(); } }
/** Closes the pool. */ public synchronized void shutdown() { while (!waitingThreads.isEmpty()) { Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1); poolable.shutdown(); } while (!runningThreads.isEmpty()) { Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1); poolable.shutdown(); } }
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };
void repool(Poolable pPoolable) { boolean discarding = false; Task task = null; Poolable poolable = null; synchronized (this) { if (runningThreads.remove(pPoolable)) { if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) { discarding = true; } else { waitingThreads.add(pPoolable); if (waitingTasks.size() > 0) { task = (Task) waitingTasks.remove(waitingTasks.size() - 1); poolable = getPoolable(task, false); } } } else { discarding = true; } if (discarding) { remove(pPoolable); } } if (poolable != null) { poolable.start(task); } if (discarding) { pPoolable.shutdown(); } }
public void run() { while (!shuttingDown) { final Task t = getTask(); if (t == null) { try { synchronized (this) { if (!shuttingDown && getTask() == null) { wait(); } } } catch (InterruptedException e) { // Do nothing } } else { try { t.run(); resetTask(); repool(Poolable.this); } catch (Throwable e) { remove(Poolable.this); Poolable.this.shutdown(); resetTask(); } } } } };