All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.parosproxy.paros.common.ThreadPool Maven / Gradle / Ivy

Go to download

The Zed Attack Proxy (ZAP) is an easy to use integrated penetration testing tool for finding vulnerabilities in web applications. It is designed to be used by people with a wide range of security experience and as such is ideal for developers and functional testers who are new to penetration testing. ZAP provides automated scanners as well as a set of tools that allow you to find security vulnerabilities manually.

There is a newer version: 2.15.0
Show newest version
/*
 *
 * Paros and its related class files.
 * 
 * Paros is an HTTP/HTTPS proxy for assessing web application security.
 * Copyright (C) 2003-2004 Chinotec Technologies Company
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the Clarified Artistic License
 * as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * Clarified Artistic License for more details.
 * 
 * You should have received a copy of the Clarified Artistic License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
// ZAP: 2014/04/01 Changed to allow to set a name to created threads.
// ZAP: 2016/09/22 JavaDoc tweaks
package org.parosproxy.paros.common;


public class ThreadPool {

	private Thread[]	pool		= null;
	private final String threadsBaseName;
	
	public ThreadPool(int maxThreadCount) {
		this(maxThreadCount, null);
	}

	public ThreadPool(int maxThreadCount, String threadsBaseName) {
		pool = new Thread[maxThreadCount];
		this.threadsBaseName = threadsBaseName;
	}

	/**
	 * Gets a free thread from the thread pool. If there is no free thread, returns {@code null}.
	 * 
	 * @param runnable the {@code Runnable} to be run in the thread
	 * @return the {@code Thread}, already started, with the given {@code Runnable}, or {@code null} if none available.
	 */
	public synchronized Thread getFreeThreadAndRun(Runnable runnable) {
	    
		for (int i=0; i
	 * If not completed yet, do not wait. Each thread should kill itself.
	 * @param waitInMillis the number of milliseconds to wait for the threads
	 */
	public void waitAllThreadComplete(int waitInMillis) {
		for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy