зеркало из https://github.com/mono/ikvm-fork.git
Move getThreads() to native code for reusing on other place. This is also more like the Java behavior.
This commit is contained in:
Родитель
1011c474e7
Коммит
8492d64fe6
|
@ -2047,20 +2047,7 @@ class Thread implements Runnable {
|
|||
|
||||
private static native StackTraceElement[] getStackTrace(cli.System.Diagnostics.StackTrace stack);
|
||||
|
||||
private static Thread[] getThreads() {
|
||||
return (Thread[])AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public Object run() {
|
||||
ThreadGroup root = getMainThreadGroup();
|
||||
for (; ; ) {
|
||||
Thread[] threads = new Thread[root.activeCount()];
|
||||
if (root.enumerate(threads) == threads.length) {
|
||||
return threads;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
private static native Thread[] getThreads();
|
||||
|
||||
/**
|
||||
* Returns the identifier of this Thread. The thread ID is a positive
|
||||
|
|
|
@ -3503,6 +3503,27 @@ namespace IKVM.NativeCode.java
|
|||
return stackTrace.ToArray();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static object getThreads()
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
return global::java.security.AccessController.doPrivileged(global::ikvm.runtime.Delegates.toPrivilegedAction(delegate
|
||||
{
|
||||
jlThreadGroup root = (jlThreadGroup)mainThreadGroup;
|
||||
for (; ; )
|
||||
{
|
||||
jlThread[] threads = new jlThread[root.activeCount()];
|
||||
if (root.enumerate(threads) == threads.Length)
|
||||
{
|
||||
return threads;
|
||||
}
|
||||
}
|
||||
}));
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class ProcessImpl
|
||||
|
|
Загрузка…
Ссылка в новой задаче