Class VirtualThreadGroup
- an receiving end-point in the server,
- a server session with another server,
- an application session,
- a client session, or
- a VirtualSpace Viewer session for development servers.
- What these thread groups have in common is that the threads used needs to be tracked and also hold "thread local" data (for virtual threads). The amount of "parked" threads, being virtual or not is set per thread group. This also applies to precreated non-started threads (virtual or native). - It should be noted that virtual threads are in general preferred to native threads. 
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- VirtualThreadGroup- (ThreadGroupType type, String name) Constructs the thread group without any- sessionInfoset, i.e.- VirtualThreadGroup- (ThreadGroupType type, String name, SessionInfo sessionInfo) Constructs the thread group.- VirtualThreadGroup- (ThreadGroupType type, String name, SessionInfo sessionInfo, ClassLoader contextClassLoader) Constructs the thread group.
- Method SummaryModifier and TypeMethodDescription- createThread- (Runnable runnable) Creates a new unstarted thread for the thread group in question.- static ThreadDataGets the inheritable thread data for the current thread.Gets the Loggers used for the current thread.Gets the session information for the current thread.- getName()Gets the name of the VirtualThreadGroup.- static final ThreadGroupGets the system thread group when platform threads should be used.- static final VirtualThreadGroupThe VirtualThreadGroup of the system, being of platforms type.Gets the ThreadFactory initialized for the ThreadGroupType.Gets the ThreadGroup associated.- getType()Gets the type of the virtual thread group.Gets a new executor service associated with this thread group.- boolean- setMaximumThreadPriority- (int maximumPriority) For platform threads, sets the maximum thread priority for the thread group.- void- setSessionInfo- (SessionInfo sessionInfo) The session information if not previously set.- startThread- (Runnable runnable) Creates a new started thread for the thread group in question.- startThread- (Runnable runnable, String name) Creates a new started thread for the thread group in question.- startThread- (Runnable runnable, String name, int priority) Creates a new started thread for the thread group in question.- toString()Returns a string identifying this VirtualThreadGroup, etc...- booleanChecks if virtual threads are used for this thread group.
- Constructor Details- VirtualThreadGroupConstructs the thread group without any- sessionInfoset, i.e. set to- nullinitially.- Parameters:
- type- The type of thread group.
- name- The name of the thread group, typically used for logging.
 
- VirtualThreadGroupConstructs the thread group.- Parameters:
- type- The type of thread group.
- name- The name of the thread group, typically used for logging.
- sessionInfo- The session information,- nullfor none.
- Throws:
- IllegalArgumentException- If- startis negative.
 
- VirtualThreadGrouppublic VirtualThreadGroup- (ThreadGroupType type, String name, SessionInfo sessionInfo, ClassLoader contextClassLoader) Constructs the thread group.- Parameters:
- type- The type of thread group.
- name- The name of the thread group, typically used for logging.
- sessionInfo- The session information,- nullfor none.
- contextClassLoader- The context class loader for threads,- nullfor none.
- Throws:
- IllegalArgumentException- If- startis negative.
 
 
- Method Details- getCurrentThreadDataGets the inheritable thread data for the current thread.- Returns:
- The ThreadData, or nullif not found.
 
- getSystemThreadGroupGets the system thread group when platform threads should be used.- Returns:
- The topmost thread group named IIZI.
 
- getSystemVirtualThreadGroupThe VirtualThreadGroup of the system, being of platforms type.- Returns:
- The system VirtualThreadGroup.
 
- getNameGets the name of the VirtualThreadGroup.- Returns:
- The name.
 
- getTypeGets the type of the virtual thread group.- Returns:
- The type.
 
- usesVirtualThreadspublic boolean usesVirtualThreads()Checks if virtual threads are used for this thread group.
- setMaximumThreadPrioritypublic boolean setMaximumThreadPriority- (int maximumPriority) For platform threads, sets the maximum thread priority for the thread group. If this thread group uses virtual threads, this call performs nothing.- First, the - checkAccessmethod of this thread group is called with no arguments; this may result in a security exception.- If the - maximumPriorityargument is less than- Thread.MIN_PRIORITYor greater than- Thread.MAX_PRIORITY, the maximum priority of the group remains unchanged.- Otherwise, the priority of this ThreadGroup object is set to the smaller of the specified - maximumPriorityand the maximum permitted priority of the parent of this thread group. (If this thread group is the system thread group, which has no parent, then its maximum priority is simply set to- maximumPriority.) Then this method is called recursively, with- maximumPriorityas its argument, for every thread group that belongs to this thread group.- Parameters:
- maximumPriority- The new maximum priority of the thread group.
- Returns:
- truefor success,- falsefor failure.
- Throws:
- SecurityException- If the current thread cannot modify this thread group.
- See Also:
 
- getThreadGroupGets the ThreadGroup associated.- Returns:
- The platform ThreadGroup if not using virtual threads, otherwise nullwhen the VirtualThreadGroup instance used virtual threads.
 
- getThreadFactoryGets the ThreadFactory initialized for the ThreadGroupType. It can be platform or virtual threads factory.- Returns:
- The thread factory.
 
- setSessionInfoThe session information if not previously set. It DOES NOT affect the current thread.- Parameters:
- sessionInfo- The session information.
- Throws:
- NullPointerException- If- sessionInfois- null.
- IllegalStateException- If the- sessionInfohas been set before.
 
- getCurrentThreadLoggersGets the Loggers used for the current thread.- Returns:
- The Loggers instance, never null.
 
- getCurrentThreadSessionInfoGets the session information for the current thread.- Returns:
- The SessionInfo instance, or nullif none is set.
 
- newExecutorServiceGets a new executor service associated with this thread group. Please note that the executor service should be closed once it has completed its mission.- Returns:
- The virtual or platform executor service associated with this group.
 
- createThreadCreates a new unstarted thread for the thread group in question.- Parameters:
- The- runnable.
- Returns:
- The unstarted thread.
 
- startThreadCreates a new started thread for the thread group in question.- Parameters:
- The- runnable.
- Returns:
- The started thread.
 
- startThreadCreates a new started thread for the thread group in question.- Parameters:
- runnable- The runnable.
- name- The thread name, or- nullfor none.
- Returns:
- The started thread.
 
- startThreadCreates a new started thread for the thread group in question.- Parameters:
- runnable- The runnable.
- name- The thread name, or- nullfor none.
- priority- The thread priority (ignored for virtual threads).
- Returns:
- The started thread.
- Throws:
- IllegalArgumentException- if the priority is not in the range- Thread#MIN_PRIORITYto- Thread#MAX_PRIORITY.
 
- toStringReturns a string identifying this VirtualThreadGroup, etc...