Class AppContextInfo
- java.lang.Object
-
- com.jogamp.nativewindow.awt.AppContextInfo
-
public class AppContextInfo extends Object
Instance of this class holds information about aThreadGroupassociatedsun.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 ThreadGroupgetCachedThreadGroup()Returns theThreadGroupbelonging to the last knownsun.awt.AppContextas queried viaupdate(String).RunnableTaskinvokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)Invokesrunnableon aThreadbelonging to thesun.awt.AppContextThreadGroup, seegetCachedThreadGroup().booleanisValid()Returnstrueif this instance has validsun.awt.AppContextinformation, i.e.booleanupdate(String info)Updatesun.awt.AppContextinformation for the current ThreadGroup if uninitialized orsun.awt.AppContextchanged.
-
-
-
Constructor Detail
-
AppContextInfo
public AppContextInfo(String info)
-
-
Method Detail
-
isValid
public final boolean isValid()
Returnstrueif this instance has validsun.awt.AppContextinformation, i.e.getCachedThreadGroup()returns notnull.
-
getCachedThreadGroup
public final ThreadGroup getCachedThreadGroup()
Returns theThreadGroupbelonging to the last knownsun.awt.AppContextas queried viaupdate(String).Returns
nullif nosun.awt.AppContexthas been queried.The returned
ThreadGroupallows 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.
JAWTWindowissuesupdate(String)in it's constructor.
-
invokeOnAppContextThread
public RunnableTask invokeOnAppContextThread(boolean waitUntilDone, Runnable runnable, String threadBaseName)
Invokesrunnableon aThreadbelonging to thesun.awt.AppContextThreadGroup, seegetCachedThreadGroup().update(String)is issued first, which returnstrueif the current thread belongs to an AppContextThreadGroup. In this case therunnableis invoked on the current thread, otherwise a newThreadwill be started.If a new
Threadis required, the AppContextThreadGroupis being used ifavailable, otherwise the default systemThreadGroup.- Parameters:
waitUntilDone- iftrue, waits untilrunnableexecution is completed, otherwise returns immediately.runnable- theRunnableto be executed. IfwaitUntilDoneistrue, 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
Threadused to invoke therunnable, which may be the currentThreador a newly created one, see above.
-
update
public final boolean update(String info)
Updatesun.awt.AppContextinformation for the current ThreadGroup if uninitialized orsun.awt.AppContextchanged.See
getCachedThreadGroup()for usage.- Parameters:
info- informal string for logging purposes- Returns:
trueif the current ThreadGroup is mapped to ansun.awt.AppContextand the information is good, otherwise false.
-
-