summaryrefslogtreecommitdiffstats
path: root/tests/039-join-main
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:28:47 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 19:28:47 -0800
commitf6c387128427e121477c1b32ad35cdcaa5101ba3 (patch)
tree2aa25fa8c8c3a9caeecf98fd8ac4cd9b12717997 /tests/039-join-main
parentf72d5de56a522ac3be03873bdde26f23a5eeeb3c (diff)
downloadandroid_dalvik-f6c387128427e121477c1b32ad35cdcaa5101ba3.tar.gz
android_dalvik-f6c387128427e121477c1b32ad35cdcaa5101ba3.tar.bz2
android_dalvik-f6c387128427e121477c1b32ad35cdcaa5101ba3.zip
auto import from //depot/cupcake/@135843
Diffstat (limited to 'tests/039-join-main')
-rw-r--r--tests/039-join-main/expected.txt5
-rw-r--r--tests/039-join-main/info.txt6
-rw-r--r--tests/039-join-main/src/Main.java42
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/039-join-main/expected.txt b/tests/039-join-main/expected.txt
new file mode 100644
index 000000000..37e6d777b
--- /dev/null
+++ b/tests/039-join-main/expected.txt
@@ -0,0 +1,5 @@
+Starting thread 'Joiner'
+@ JoinMainSub running
+JoinMain starter returning
+@ JoinMainSub successfully joined main
+@ JoinMainSub bailing
diff --git a/tests/039-join-main/info.txt b/tests/039-join-main/info.txt
new file mode 100644
index 000000000..08127da23
--- /dev/null
+++ b/tests/039-join-main/info.txt
@@ -0,0 +1,6 @@
+This is a miscellaneous test that was imported into the new-at-the-time
+runtime test framework. The test is intended to exercise basic features,
+and as such cannot be build on top of junit, since failure of such basic
+features might disrupt junit.
+
+TODO: Real description goes here.
diff --git a/tests/039-join-main/src/Main.java b/tests/039-join-main/src/Main.java
new file mode 100644
index 000000000..8d66b5859
--- /dev/null
+++ b/tests/039-join-main/src/Main.java
@@ -0,0 +1,42 @@
+// Copyright 2007 The Android Open Source Project
+
+/**
+ * Make sure that a sub-thread can join the main thread.
+ */
+public class Main {
+ public static void main(String[] args) {
+ Thread t;
+
+ t = new Thread(new JoinMainSub(Thread.currentThread()), "Joiner");
+ System.out.print("Starting thread '" + t.getName() + "'\n");
+ t.start();
+
+ try { Thread.sleep(1000); }
+ catch (InterruptedException ie) {}
+
+ System.out.print("JoinMain starter returning\n");
+ }
+}
+
+class JoinMainSub implements Runnable {
+ private Thread mJoinMe;
+
+ public JoinMainSub(Thread joinMe) {
+ mJoinMe = joinMe;
+ }
+
+ public void run() {
+ System.out.print("@ JoinMainSub running\n");
+
+ try {
+ mJoinMe.join();
+ System.out.print("@ JoinMainSub successfully joined main\n");
+ } catch (InterruptedException ie) {
+ System.out.print("@ JoinMainSub interrupted!\n");
+ }
+ finally {
+ System.out.print("@ JoinMainSub bailing\n");
+ }
+ }
+}
+