private boolean startThreads(int threadsToStart) { while (threadsToStart > 0 && isRunning()) { int threads = _threadsStarted.get(); if (threads >= _maxThreads) return false; if (!_threadsStarted.compareAndSet(threads, threads + 1)) continue; boolean started = false; try { Thread thread = newThread(_runnable); thread.setDaemon(isDaemon()); thread.setPriority(getThreadsPriority()); thread.setName(_name + "-" + thread.getId()); _threads.add(thread); _lastShrink.set(System.nanoTime()); thread.start(); started = true; --threadsToStart; } finally { if (!started) _threadsStarted.decrementAndGet(); } } return true; }
private boolean startThread(int threads) { final int next=threads+1; if (!_threadsStarted.compareAndSet(threads,next)) return false; boolean started=false; try { Thread thread=newThread(_runnable); thread.setDaemon(_daemon); thread.setPriority(_priority); thread.setName(_name+"-"+thread.getId()); _threads.add(thread); thread.start(); started=true; } finally { if (!started) _threadsStarted.decrementAndGet(); } return started; }
private boolean startThread(int threads) { final int next=threads+1; if (!_threadsStarted.compareAndSet(threads,next)) return false; boolean started=false; try { Thread thread=newThread(_runnable); thread.setDaemon(_daemon); thread.setPriority(_priority); thread.setName(_name+"-"+thread.getId()); _threads.add(thread); thread.start(); started=true; } finally { if (!started) _threadsStarted.decrementAndGet(); } return started; }
private boolean startThread(int threads) { final int next=threads+1; if (!_threadsStarted.compareAndSet(threads,next)) return false; boolean started=false; try { Thread thread=newThread(_runnable); thread.setDaemon(_daemon); thread.setPriority(_priority); thread.setName(_name+"-"+thread.getId()); _threads.add(thread); thread.start(); started=true; } finally { if (!started) _threadsStarted.decrementAndGet(); } return started; }
private boolean startThread(int threads) { final int next=threads+1; if (!_threadsStarted.compareAndSet(threads,next)) return false; boolean started=false; try { Thread thread=newThread(_runnable); thread.setDaemon(_daemon); thread.setPriority(_priority); thread.setName(_name+"-"+thread.getId()); _threads.add(thread); thread.start(); started=true; } finally { if (!started) _threadsStarted.decrementAndGet(); } return started; }
private boolean startThreads(int threadsToStart) { while (threadsToStart > 0) { int threads = _threadsStarted.get(); if (threads >= _maxThreads) return false; if (!_threadsStarted.compareAndSet(threads, threads + 1)) continue; boolean started = false; try { Thread thread = newThread(_runnable); thread.setDaemon(isDaemon()); thread.setPriority(getThreadsPriority()); thread.setName(_name + "-" + thread.getId()); _threads.add(thread); thread.start(); started = true; } finally { if (!started) _threadsStarted.decrementAndGet(); } if (started) threadsToStart--; } return true; }
private boolean startThreads(int threadsToStart) { while (threadsToStart > 0) { int threads = _threadsStarted.get(); if (threads >= _maxThreads) return false; if (!_threadsStarted.compareAndSet(threads, threads + 1)) continue; boolean started = false; try { Thread thread = newThread(_runnable); thread.setDaemon(isDaemon()); thread.setPriority(getThreadsPriority()); thread.setName(_name + "-" + thread.getId()); _threads.add(thread); thread.start(); started = true; } finally { if (!started) _threadsStarted.decrementAndGet(); } if (started) threadsToStart--; } return true; }
private boolean startThreads(int threadsToStart) { while (threadsToStart > 0 && isRunning()) { int threads = _threadsStarted.get(); if (threads >= _maxThreads) return false; if (!_threadsStarted.compareAndSet(threads, threads + 1)) continue; boolean started = false; try { Thread thread = newThread(_runnable); thread.setDaemon(isDaemon()); thread.setPriority(getThreadsPriority()); thread.setName(_name + "-" + thread.getId()); _threads.add(thread); _lastShrink.set(System.nanoTime()); thread.start(); started = true; --threadsToStart; } finally { if (!started) _threadsStarted.decrementAndGet(); } } return true; }
private boolean startThreads(int threadsToStart) { while (threadsToStart > 0 && isRunning()) { int threads = _threadsStarted.get(); if (threads >= _maxThreads) return false; if (!_threadsStarted.compareAndSet(threads, threads + 1)) continue; boolean started = false; try { Thread thread = newThread(_runnable); thread.setDaemon(isDaemon()); thread.setPriority(getThreadsPriority()); thread.setName(_name + "-" + thread.getId()); _threads.add(thread); thread.start(); started = true; --threadsToStart; } finally { if (!started) _threadsStarted.decrementAndGet(); } } return true; }