Class AppContextInfo
ThreadGroup
associated AppContext
.
Non intrusive workaround for Bug 983 and Bug 1004, see getCachedThreadGroup()
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ThreadGroup
invokeOnAppContextThread
(boolean waitUntilDone, Runnable runnable, String threadBaseName) final boolean
isValid()
Returnstrue
if this instance has validAppContext
information, i.e.final boolean
UpdateAppContext
information for the current ThreadGroup if uninitialized orAppContext
changed.
-
Constructor Details
-
AppContextInfo
-
-
Method Details
-
isValid
public final boolean isValid()Returnstrue
if this instance has validAppContext
information, i.e.getCachedThreadGroup()
returns notnull
. -
getCachedThreadGroup
Returns theThreadGroup
belonging to the last knownAppContext
as queried viaupdate(String)
.Returns
null
if noAppContext
has been queried.The returned
ThreadGroup
allows users to create a custom thread belonging to it and hence mitigating Bug 983 and Bug 1004.update(String)
should be called from a thread belonging to the desiredAppContext
, i.e. early from within the special threaded application.E.g.
JAWTWindow
issuesupdate(String)
in it's constructor. -
invokeOnAppContextThread
public Thread invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName) Invokesrunnable
on aThread
belonging to theAppContext
ThreadGroup
, seegetCachedThreadGroup()
.update(String)
is issued first, which returnstrue
if the current thread belongs to an AppContextThreadGroup
. In this case therunnable
is invoked on the current thread, otherwise a newThread
will be started.If a new
Thread
is required, the AppContextThreadGroup
is being used ifavailable
, otherwise the default systemThreadGroup
.- Parameters:
waitUntilDone
- iftrue
, waits untilrunnable
execution is completed, otherwise returns immediately.runnable
- theRunnable
to be executed. IfwaitUntilDone
istrue
, the runnable must exist, i.e. not loop forever.threadBaseName
- the base name for the new thread if required. The resulting thread name will have either '-OnAppContextTG' or '-OnSystemTG' appended- Returns:
- the
Thread
used to invoke therunnable
, which may be the currentThread
or a newly created one, see above.
-
update
UpdateAppContext
information for the current ThreadGroup if uninitialized orAppContext
changed.See
getCachedThreadGroup()
for usage.- Parameters:
info
- informal string for logging purposes- Returns:
true
if the current ThreadGroup is mapped to anAppContext
and the information is good, otherwise false.
-