summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-09 21:37:32 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2006-06-09 21:37:32 +0000
commit8a5d137dbca185c626aa590df1a66df61080c6a7 (patch)
tree768266d9db63e861f05c341e56228901388cdd52
parent8457a4ae3c017961686ec29edc856b8c165b271e (diff)
downloadgcc-8a5d137dbca185c626aa590df1a66df61080c6a7.tar.gz
PR libgcj/27730:
* java/lang/Thread.java (threadId): New field. (nextThreadId): New static field. (Thread): Initialize new field. (getId): New method. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114524 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog8
-rw-r--r--libjava/java/lang/Thread.java25
2 files changed, 32 insertions, 1 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index b5b4ef4cdf8..838ecf3e3d3 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,5 +1,13 @@
2006-06-09 Tom Tromey <tromey@redhat.com>
+ PR libgcj/27730:
+ * java/lang/Thread.java (threadId): New field.
+ (nextThreadId): New static field.
+ (Thread): Initialize new field.
+ (getId): New method.
+
+2006-06-09 Tom Tromey <tromey@redhat.com>
+
* java/lang/Class.java (getClassLoaderInternal): Now native.
2006-06-09 Thomas Fitzsimmons <fitzsim@redhat.com>
diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java
index 505b99baf20..bac1afd061d 100644
--- a/libjava/java/lang/Thread.java
+++ b/libjava/java/lang/Thread.java
@@ -127,6 +127,12 @@ public class Thread implements Runnable
/** The context classloader for this Thread. */
private ClassLoader contextClassLoader;
+ /** This thread's ID. */
+ private final long threadId;
+
+ /** The next thread ID to use. */
+ private static long nextThreadId;
+
/** The default exception handler. */
private static UncaughtExceptionHandler defaultHandler;
@@ -354,12 +360,17 @@ public class Thread implements Runnable
}
else
group = g;
-
+
data = null;
interrupt_flag = false;
alive_flag = false;
startable_flag = true;
+ synchronized (Thread.class)
+ {
+ this.threadId = nextThreadId++;
+ }
+
if (current != null)
{
group.checkAccess();
@@ -1027,6 +1038,18 @@ public class Thread implements Runnable
return defaultHandler;
}
+ /**
+ * Returns the unique identifier for this thread. This ID is generated
+ * on thread creation, and may be re-used on its death.
+ *
+ * @return a positive long number representing the thread's ID.
+ * @since 1.5
+ */
+ public long getId()
+ {
+ return threadId;
+ }
+
/**
* <p>
* This interface is used to handle uncaught exceptions