/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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 GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class implements a {@link com.sun.jmx.snmp.tasks.TaskServer} over
* a thread pool.
* <p><b>This API is a Sun Microsystems internal API and is subject
* to change without notice.</b></p>
**/
if (threadNumber <= 0) {
throw new IllegalArgumentException("The thread number should bigger than zero.");
}
}
// public methods
// --------------
/**
* Submit a task to be executed.
* Once a task is submitted, it is guaranteed that either
* {@link com.sun.jmx.snmp.tasks.Task#run() task.run()} or
* {@link com.sun.jmx.snmp.tasks.Task#cancel() task.cancel()} will be called.
* This implementation of TaskServer uses a thread pool to execute
* the submitted tasks.
* @param task The task to be executed.
* @exception IllegalArgumentException if the submitted task is null.
**/
}
/**
* Submit a task to be executed.
* This implementation of TaskServer uses a thread pool to execute
* the submitted tasks.
* @param task The task to be executed.
* @exception IllegalArgumentException if the submitted task is null.
**/
stateCheck();
throw new IllegalArgumentException("No task specified.");
}
synchronized(jobList) {
}
createThread();
}
stateCheck();
synchronized(jobList) {
if (lg >= 0) {
}
}
return removed;
}
public void removeAll() {
stateCheck();
synchronized(jobList) {
}
for (int i=0; i<len ; i++) {
}
}
// to terminate
public void terminate() {
if (terminated == true) {
return;
}
terminated = true;
synchronized(jobList) {
}
removeAll();
for (int i=0; i<currThreds; i++) {
try {
threadList[i].interrupt();
} catch (Exception e) {
// TODO
}
}
threadList = null;
}
// private classes
// ---------------
// A thread used to execute jobs
//
public ExecutorThread() {
setDaemon(true);
// init
this.setPriority(priority);
this.setContextClassLoader(cloader);
idle++;
}
public void run() {
while(!terminated) {
synchronized(jobList) {
}
} else {
try {
} catch (InterruptedException ie) {
// terminated ?
} finally {
}
continue;
}
}
try {
idle--;
} catch (Exception e) {
// TODO
e.printStackTrace();
} finally {
idle++;
}
}
// re-init
this.setPriority(priority);
this.interrupted();
this.setContextClassLoader(cloader);
}
}
}
// private methods
if (terminated) {
throw new IllegalStateException("The thread service has been terminated.");
}
}
private void createThread() {
if (idle < 1) {
synchronized(threadList) {
}
}
}
}
// protected or private variables
// ------------------------------
private boolean terminated = false;
private int priority;
}