|
JNA API> 4.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jna.CallbackThreadInitializer
public class CallbackThreadInitializer
This class provides for customization of the mapping of native threads
onto attached Java threads. Use
Native.setCallbackThreadInitializer(com.sun.jna.Callback, com.sun.jna.CallbackThreadInitializer)
to customize the thread context
in which a given callback is invoked.
CallbackThreadInitiailizer
is
registered for that callback, the initializer object will be used to
determine how the thread should be attached to the VM.
Once attached, the method Native.detach(boolean)
may be used from within
the callback invocation to alter whether the thread will be detached or not
when the callback finishes execution. Typically this functionality is used
in situations where you expect a callback to be called repeatedly from the
same thread and you want to avoid potential extra thread allocation
overhead on each callback invocation, since the VM may or may not re-use
the same allocated thread object each time the thread is attached.
A single initializer may be used for multiple callbacks, one initializer
per callback, or you may subclass the initializer to provide different
initializer settings depending on the callback.
Constructor Summary | |
---|---|
CallbackThreadInitializer()
The default initializer causes the callback thread to remain attached as a daemon thread, using the default thread name and group. |
|
CallbackThreadInitializer(boolean daemon)
Keep the callback thread attached, with the given daemon state, using the default thread name and group. |
|
CallbackThreadInitializer(boolean daemon,
boolean detach)
Uses the default thread name and group. |
|
CallbackThreadInitializer(boolean daemon,
boolean detach,
String name)
Uses the default thread group. |
|
CallbackThreadInitializer(boolean daemon,
boolean detach,
String name,
ThreadGroup group)
Specify all aspects of how the callback thread should be initialized. |
Method Summary | |
---|---|
boolean |
detach(Callback cb)
Returns whether the Thread should be detached from the VM after the callback exits, if the thread was not already attached to begin with. |
String |
getName(Callback cb)
Returns the desired name for this thread, or null for the default. |
ThreadGroup |
getThreadGroup(Callback cb)
Returns the desired ThreadGroup for thread, or null for the default. |
boolean |
isDaemon(Callback cb)
Returns whether the callback thread should be a daemon thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CallbackThreadInitializer()
public CallbackThreadInitializer(boolean daemon)
public CallbackThreadInitializer(boolean daemon, boolean detach)
public CallbackThreadInitializer(boolean daemon, boolean detach, String name)
public CallbackThreadInitializer(boolean daemon, boolean detach, String name, ThreadGroup group)
Method Detail |
---|
public String getName(Callback cb)
public ThreadGroup getThreadGroup(Callback cb)
public boolean isDaemon(Callback cb)
public boolean detach(Callback cb)
|
JNA API> 4.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |