Package com.avpkit.ferry
Class JNIThreadProxy
- java.lang.Object
-
- java.lang.Thread
-
- com.avpkit.ferry.JNIThreadProxy
-
- All Implemented Interfaces:
java.lang.Runnable
public class JNIThreadProxy extends java.lang.Thread
Proxy forThreadthat is called by Ferry native code.This class is called from native code to tell if a thread is interrupted. It only exposes the methods that are called from the native code, and adds logging to aid in debugging.
If allows a global handler to be set. This can be useful for catching threads that are started from native code as there is no other way to detect those and interrupt them. If set, the global handler will always be checked BEFORE the local thread allowing users to always get a callback on each interrupt check if they want.
Do not change the name or location of this class without also changing the JNIHelper.cpp code that refers to it.
- Since:
- 5.0
- Author:
- aclarke
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceJNIThreadProxy.InterruptableInterface that global interrupt handlers should use.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.ThreadcurrentThread()static JNIThreadProxy.InterruptablegetGlobalInterruptHandler()Gets the current global interrupt handlervoidinterrupt()booleanisInterrupted()static JNIThreadProxy.InterruptablesetGlobalInterruptable(JNIThreadProxy.Interruptable handler)Set a new global interrupt handler.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, join, join, join, onSpinWait, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Method Detail
-
getGlobalInterruptHandler
public static JNIThreadProxy.Interruptable getGlobalInterruptHandler()
Gets the current global interrupt handler- Returns:
- The handler, or null if not set.
-
setGlobalInterruptable
public static JNIThreadProxy.Interruptable setGlobalInterruptable(JNIThreadProxy.Interruptable handler)
Set a new global interrupt handler.- Parameters:
handler- The new handler to use, or null to disable.- Returns:
- The previous handler, or null if none is set.
-
currentThread
public static java.lang.Thread currentThread()
- Returns:
- java.lang.Thread
- See Also:
Thread.currentThread()
-
isInterrupted
public boolean isInterrupted()
- Overrides:
isInterruptedin classjava.lang.Thread
-
interrupt
public void interrupt()
- Overrides:
interruptin classjava.lang.Thread
-
-