This commit is contained in:
jfrijters 2006-06-27 09:10:02 +00:00
Родитель 567c175319
Коммит 321e6eeb30
4 изменённых файлов: 228 добавлений и 24 удалений

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

@ -1207,6 +1207,10 @@
../../classpath/gnu/javax/imageio/bmp/EncodeRGB8.java
../../classpath/gnu/javax/imageio/bmp/EncodeRLE4.java
../../classpath/gnu/javax/imageio/bmp/EncodeRLE8.java
../../classpath/gnu/javax/imageio/gif/GIFFile.java
../../classpath/gnu/javax/imageio/gif/GIFImageReader.java
../../classpath/gnu/javax/imageio/gif/GIFImageReaderSpi.java
../../classpath/gnu/javax/imageio/gif/GIFStream.java
../../classpath/gnu/javax/imageio/jpeg/DCT.java
../../classpath/gnu/javax/imageio/jpeg/HuffmanTable.java
../../classpath/gnu/javax/imageio/jpeg/JPEGComponent.java
@ -2313,6 +2317,8 @@
../../classpath/java/lang/management/ManagementPermission.java
../../classpath/java/lang/management/OperatingSystemMXBean.java
../../classpath/java/lang/management/RuntimeMXBean.java
../../classpath/java/lang/management/ThreadInfo.java
../../classpath/java/lang/management/ThreadMXBean.java
../../classpath/java/lang/Math.java
../../classpath/java/lang/NegativeArraySizeException.java
../../classpath/java/lang/NoClassDefFoundError.java
@ -4613,6 +4619,7 @@ java/io/VMObjectInputStream.java
java/lang/DoubleToString.java
java/lang/ExceptionHelper.java
java/lang/LibraryVMInterfaceImpl.java
java/lang/management/VMThreadInfo.java
java/lang/ref/Reference.java
java/lang/reflect/Constructor.java
java/lang/reflect/Field.java

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

@ -1,12 +1,13 @@
package java.lang;
import java.util.concurrent.atomic.AtomicInteger;
// Note: stop() should take care not to stop a thread if it is
// executing code in this class.
@ikvm.lang.Internal
public final class VMThread
{
private static final Object countLock = new Object();
private static int nonDaemonCount;
private static final AtomicInteger nonDaemonCount = new AtomicInteger();
// used by inner class
@cli.System.ThreadStaticAttribute.Annotation
/*private*/ static Thread __tls_javaThread;
@ -80,10 +81,7 @@ public final class VMThread
nativeThreadReference.set_Target(null);
if(!thread.daemon)
{
synchronized(countLock)
{
nonDaemonCount--;
}
nonDaemonCount.decrementAndGet();
}
}
}
@ -155,19 +153,13 @@ public final class VMThread
{
if(!Thread.currentThread().isDaemon())
{
synchronized(countLock)
{
nonDaemonCount--;
}
nonDaemonCount.decrementAndGet();
}
for(;;)
{
synchronized(countLock)
if(nonDaemonCount.get() == 0)
{
if(nonDaemonCount == 0)
{
return;
}
return;
}
try
{
@ -296,7 +288,7 @@ public final class VMThread
thread.stillborn = t;
}
void start(long stacksize)
private void start(long stacksize)
{
cli.System.Threading.ThreadStart starter = new cli.System.Threading.ThreadStart(
new cli.System.Threading.ThreadStart.Method()
@ -315,10 +307,7 @@ public final class VMThread
nativeThread.Start();
if(!thread.daemon)
{
synchronized(countLock)
{
nonDaemonCount++;
}
nonDaemonCount.incrementAndGet();
}
}
@ -559,10 +548,7 @@ public final class VMThread
Thread javaThread = new Thread(vmThread, nativeThread.get_Name(), priority, nativeThread.get_IsBackground());
if(!javaThread.daemon)
{
synchronized(countLock)
{
nonDaemonCount++;
}
nonDaemonCount.incrementAndGet();
}
vmThread.thread = javaThread;
__tls_javaThread = javaThread;
@ -741,4 +727,29 @@ public final class VMThread
VMThread vmthread = t.vmThread;
return vmthread != null ? vmthread.blocker : null;
}
/**
* Returns the current state of the thread.
* The value must be one of "BLOCKED", "NEW",
* "RUNNABLE", "TERMINATED", "TIMED_WAITING" or
* "WAITING".
*
* @return a string corresponding to one of the
* thread enumeration states specified above.
*/
String getState()
{
cli.System.Threading.Thread nativeThread = (cli.System.Threading.Thread)nativeThreadReference.get_Target();
if (nativeThread != null && nativeThread.get_IsAlive())
{
if (interruptableWait)
{
// TODO we don't yet distinguish between WAITING and TIMED_WAITING
return "WAITING";
}
// TODO we don't support BLOCKED
return "RUNNABLE";
}
return "TERMINATED";
}
}

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

@ -0,0 +1,185 @@
/* VMThreadInfo.java - Information on a thread
Copyright (C) 2006 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.lang.management;
/**
* Provides low-level information about a thread.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.5
* @see java.lang.management.ThreadInfo
*/
final class VMThreadInfo
{
/**
* Return the number of times the specified thread
* has been in the {@link java.lang.Thread.State#BLOCKED}
* state.
*
* @param thread the thread to return statistics on.
* @return the number of times the thread has been blocked.
*/
static long getBlockedCount(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns the accumulated number of milliseconds the
* specified thread has spent in the
* {@link java.lang.Thread.State#BLOCKED} state. This
* method is only called if thread contention monitoring
* is both supported and enabled.
*
* @param thread the thread to return statistics on.
* @return the accumulated number of milliseconds the
* thread has been blocked for.
*/
static long getBlockedTime(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns the monitor lock the specified thread is
* waiting for. This is only called when the thread
* is in the {@link java.lang.Thread.State#BLOCKED}
* state.
*
* @param thread the thread to return statistics on.
* @return the monitor lock the thread is waiting for.
*/
static Object getLock(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns the thread which currently owns the monitor
* lock the specified thread is waiting for. This is
* only called when the thread is in the
* {@link java.lang.Thread.State#BLOCKED} state. It
* may return <code>null</code> if the lock is not held
* by another thread.
*
* @param thread the thread to return statistics on.
* @return the thread which owns the monitor lock the
* thread is waiting for, or <code>null</code>
* if it doesn't have an owner.
*/
static Thread getLockOwner(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Return the number of times the specified thread
* has been in the {@link java.lang.Thread.State#WAITING}
* or {@link java.lang.Thread.State#TIMED_WAITING} states.
*
* @param thread the thread to return statistics on.
* @return the number of times the thread has been in
* waiting state.
*/
static long getWaitedCount(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns the accumulated number of milliseconds the
* specified thread has spent in either the
* {@link java.lang.Thread.State#WAITING} or
* {@link java.lang.Thread.State#TIMED_WAITING} states.
* This method is only called if thread contention
* monitoring is both supported and enabled.
*
* @param thread the thread to return statistics on.
* @return the accumulated number of milliseconds the
* thread has been in a waiting state for.
*/
static long getWaitedTime(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns true if the specified thread is in a native
* method.
*
* @param thread the thread to return statistics on.
* @return true if the thread is in a native method, false
* otherwise.
*/
static boolean isInNative(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns true if the specified thread is suspended.
*
* @param thread the thread to return statistics on.
* @return true if the thread is suspended, false otherwise.
*/
static boolean isSuspended(Thread thread)
{
throw new UnsupportedOperationException();
}
/**
* Returns a stack trace for the specified thread of
* the supplied depth. If the depth is
* <code>Integer.MAX_VALUE</code>, then the returned
* depth is equal to the full stack trace available.
* The depth will be greater than zero, due to
* filtering in methods prior to this call.
*
* @param thread the thread whose stack trace should
* be returned.
* @param maxDepth the maximum depth of the trace.
* This will be greater than zero.
* <code>Integer.MAX_VALUE</code>
* represents the full trace.
*/
static StackTraceElement[] getStackTrace(Thread thread, int maxDepth)
{
throw new UnsupportedOperationException();
}
}

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

@ -41,6 +41,7 @@ java/io/VMObjectInputStream.java
java/lang/DoubleToString.java
java/lang/ExceptionHelper.java
java/lang/LibraryVMInterfaceImpl.java
java/lang/management/VMThreadInfo.java
java/lang/ref/Reference.java
java/lang/reflect/Constructor.java
java/lang/reflect/Field.java