com.gargoylesoftware.htmlunit
Class ThreadManager

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.ThreadManager

public class ThreadManager
extends java.lang.Object

INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
This is a class that provides thread handling services to internal clients as well as exposes some of the status of these threads to the public API.

Version:
$Revision: 1.3 $
Author:
Brad Clarke, Marc Guillemot, Daniel Gredler

Constructor Summary
ThreadManager()
  
 
Method Summary
 int activeCount()
  
 void interruptAll()
 INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
 boolean joinAll(long maxWaitMillis)
 Wait for any executing background threads to complete.
 int startThread(java.lang.Runnable job, java.lang.String label)
 INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
 void stopThread(int threadID)
 INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
 java.lang.String toString()
 
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadManager

public ThreadManager()
Method Detail

activeCount

public int activeCount()
Returns:
The number of tracked threads.

interruptAll

public void interruptAll()
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Attempts to stop running threads.


joinAll

public boolean joinAll(long maxWaitMillis)
Wait for any executing background threads to complete.

Parameters:
maxWaitMillis - The maximum time that should be waited, in milliseconds. This is not an exact time but will be fairly close.
Returns:
true if all threads expired in the specified time

startThread

public int startThread(java.lang.Runnable job,
                       java.lang.String label)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Starts a new job on a background thread. Threads started by this method are always considered daemon threads and will not prevent the JVM from shutting down. For our purposes the JUnit test is the only thread that matters and the background threads are just there to keep the HtmlUnit objects as up to date as possible.

Parameters:
job - The job to start
label - a job description
Returns:
ID of the new thread, suitable for use in JavaScript and required when calling stopThread(int)

stopThread

public void stopThread(int threadID)
INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.
Stops a thread that was started in this thread manager. Note: this does not immediately stop the thread, only interrupt it and remove it from being tracked by this manager. The thread is responsible for handling being interrupted properly and shutting itself down.

Parameters:
threadID - the ID of the thread to stop

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2003-2016 AppPerfect Corporation. All Rights Reserved.