Move getThreads() to native code for reusing on other place. This is also more like the Java behavior.

This commit is contained in:
smallsql 2012-04-15 14:43:25 +00:00
Родитель 1011c474e7
Коммит 8492d64fe6
2 изменённых файлов: 22 добавлений и 14 удалений

Просмотреть файл

@ -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