Class AppContextInfo
- java.lang.Object
-
- com.jogamp.nativewindow.awt.AppContextInfo
-
public class AppContextInfo extends Object
Instance of this class holds information about aThreadGroup
associatedsun.awt.AppContext
.Non intrusive workaround for Bug 983 and Bug 1004, see
getCachedThreadGroup()
.
-
-
Constructor Summary
Constructors Constructor Description AppContextInfo(String info)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadGroup
getCachedThreadGroup()
Returns theThreadGroup
belonging to the last knownsun.awt.AppContext
as queried viaupdate(String)
.RunnableTask
invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
Invokesrunnable
on aThread
belonging to thesun.awt.AppContext
ThreadGroup
, seegetCachedThreadGroup()
.boolean
isValid()
Returnstrue
if this instance has validsun.awt.AppContext
information, i.e.boolean
update(String info)
Updatesun.awt.AppContext
information for the current ThreadGroup if uninitialized orsun.awt.AppContext
changed.
-
-
-
Constructor Detail
-
AppContextInfo
public AppContextInfo(String info)
-
-
Method Detail
-
isValid
public final boolean isValid()
Returnstrue
if this instance has validsun.awt.AppContext
information, i.e.getCachedThreadGroup()
returns notnull
.
-
getCachedThreadGroup
public final ThreadGroup getCachedThreadGroup()
Returns theThreadGroup
belonging to the last knownsun.awt.AppContext
as queried viaupdate(String)
.Returns
null
if nosun.awt.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 desiredsun.awt.AppContext
, i.e. early from within the special threaded application.E.g.
JAWTWindow
issuesupdate(String)
in it's constructor.
-
invokeOnAppContextThread
public RunnableTask invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
Invokesrunnable
on aThread
belonging to thesun.awt.AppContext
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
public final boolean update(String info)
Updatesun.awt.AppContext
information for the current ThreadGroup if uninitialized orsun.awt.AppContext
changed.See
getCachedThreadGroup()
for usage.- Parameters:
info
- informal string for logging purposes- Returns:
true
if the current ThreadGroup is mapped to ansun.awt.AppContext
and the information is good, otherwise false.
-
-