summaryrefslogtreecommitdiffstats
path: root/test/051-thread/src/Main.java
diff options
context:
space:
mode:
Diffstat (limited to 'test/051-thread/src/Main.java')
-rw-r--r--test/051-thread/src/Main.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/051-thread/src/Main.java b/test/051-thread/src/Main.java
index 608b7e0878..390685d049 100644
--- a/test/051-thread/src/Main.java
+++ b/test/051-thread/src/Main.java
@@ -25,6 +25,7 @@ public class Main {
testThreadCapacity();
testThreadDaemons();
testSleepZero();
+ testSetName();
System.out.println("thread test done");
}
@@ -112,4 +113,24 @@ public class Main {
}
System.out.print("testSleepZero finished\n");
}
+
+ private static void testSetName() throws Exception {
+ System.out.print("testSetName starting\n");
+ Thread thread = new Thread() {
+ @Override
+ public void run() {
+ System.out.print("testSetName running\n");
+ }
+ };
+ thread.start();
+ thread.setName("HelloWorld"); // b/17302037 hang if setName called after start
+ if (!thread.getName().equals("HelloWorld")) {
+ throw new AssertionError("Unexpected thread name: " + thread.getName());
+ }
+ thread.join();
+ if (!thread.getName().equals("HelloWorld")) {
+ throw new AssertionError("Unexpected thread name after join: " + thread.getName());
+ }
+ System.out.print("testSetName finished\n");
+ }
}