public class AppContextInfo extends Object
ThreadGroup
associated AppContext
.
Non intrusive workaround for Bug 983 and Bug 1004, see getCachedThreadGroup()
.
Constructor and Description |
---|
AppContextInfo(String info) |
Modifier and Type | Method and Description |
---|---|
ThreadGroup |
getCachedThreadGroup()
|
Thread |
invokeOnAppContextThread(boolean waitUntilDone,
Runnable runnable,
String threadBaseName)
|
boolean |
isValid()
Returns
true if this instance has valid AppContext information,
i.e. |
boolean |
update(String info)
Update
AppContext information for the current ThreadGroup if uninitialized or AppContext changed. |
public AppContextInfo(String info)
public final boolean isValid()
true
if this instance has valid AppContext
information,
i.e. getCachedThreadGroup()
returns not null
.public final ThreadGroup getCachedThreadGroup()
ThreadGroup
belonging to the
last known AppContext
as queried via update(String)
.
Returns null
if no AppContext
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
desired AppContext
, i.e. early from within the special threaded application.
E.g. JAWTWindow
issues update(String)
in it's constructor.
public Thread invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
runnable
on a Thread
belonging to the AppContext
ThreadGroup
,
see getCachedThreadGroup()
.
update(String)
is issued first, which returns true
if the current thread belongs to an AppContext ThreadGroup
.
In this case the runnable
is invoked on the current thread,
otherwise a new Thread
will be started.
If a new Thread
is required, the AppContext ThreadGroup
is being used
if available
, otherwise the default system ThreadGroup
.
waitUntilDone
- if true
, waits until runnable
execution is completed, otherwise returns immediately.runnable
- the Runnable
to be executed. If waitUntilDone
is true
,
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' appendedThread
used to invoke the runnable
, which may be the current Thread
or a newly created one, see above.public final boolean update(String info)
AppContext
information for the current ThreadGroup if uninitialized or AppContext
changed.
See getCachedThreadGroup()
for usage.
info
- informal string for logging purposestrue
if the current ThreadGroup is mapped to an AppContext
and the information is good, otherwise false.Copyright 2010 JogAmp Community.