Package com.seeq.link.sdk.utilities
Class ThreadCollection
java.lang.Object
com.seeq.link.sdk.utilities.ThreadCollection
A facility that manages a collection of background threads that need to be spawned and potentially all interrupted in
a controlled way.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getCount()
The count of all background threads being managed by this collection.getID()
An identifier used in log output for this object.void
interrupt
(long requestId) Interrupt a request, given the identifier supplied when the request was created.protected boolean
void
An identifier used in log output for this object.void
Shuts down all threads being managed in this collection and does not return until they are verified to have died.Spawns a thread that executes the supplied callback.Spawns a thread that executes the supplied callback.Spawns a thread that executes the supplied callback.Spawns a thread that executes the supplied callback.
-
Field Details
-
NO_TIMEOUT
public static final int NO_TIMEOUT- See Also:
-
UNINTERRUPTABLE_ID
public static final int UNINTERRUPTABLE_ID- See Also:
-
-
Constructor Details
-
ThreadCollection
public ThreadCollection() -
ThreadCollection
-
-
Method Details
-
getID
An identifier used in log output for this object.- Returns:
- an identifier used in log output for this object
-
setID
An identifier used in log output for this object.- Parameters:
id
- an identifier used in log output for this object
-
spawn
Spawns a thread that executes the supplied callback.- Parameters:
callback
- The callback that represents the task to be performed- Returns:
- the Thread object that was spawned
-
spawn
Spawns a thread that executes the supplied callback.- Parameters:
callback
- The callback that represents the task to be performedpriority
- The desired thread priority; seeThread.setPriority(int)
- Returns:
- the Thread object that was spawned
-
spawn
Spawns a thread that executes the supplied callback.- Parameters:
callback
- The callback that represents the task to be performedtimeoutMillis
- How long the request remains valid. After timeoutMillis milliseconds, the request should be interrupted, to free up resources for future requests.requestId
- An identifier for the request which must be greater than or equal to 0 and unique to the connection. This ID allows for subsequent cancellation messages to be associated with the same request.- Returns:
- the Thread object that was spawned
-
spawn
Spawns a thread that executes the supplied callback.- Parameters:
callback
- The callback that represents the task to be performedtimeoutMillis
- How long the request remains valid. After timeoutMillis milliseconds, the request should be interrupted, to free up resources for future requests.requestId
- An identifier for the request which must be greater than or equal to 0 and unique to the connection. This ID allows for subsequent cancellation messages to be associated with the same request.priority
- The desired thread priority; seeThread.setPriority(int)
- Returns:
- the Thread object that was spawned
-
interrupt
public void interrupt(long requestId) Interrupt a request, given the identifier supplied when the request was created. Note: interrupting a request does not mean it will terminate immediately, or at all. It only means that the interrupted flag will be set on the thread. Some connectors will watch for this flag and terminate the request, but others may not.- Parameters:
requestId
- the identifier supplied when the request was created
-
shutDownAll
public void shutDownAll()Shuts down all threads being managed in this collection and does not return until they are verified to have died. -
getCount
public int getCount()The count of all background threads being managed by this collection.- Returns:
- the count of all background threads
-
isShutdown
protected boolean isShutdown()
-