2 * Copyright (C) 2006 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 import java.util.ArrayList;
20 * Test some basic thread stuff.
23 public static void main(String[] args) throws Exception {
24 System.out.println("Initializing System.out...");
26 MyThread[] threads = new MyThread[512];
27 for (int i = 0; i < 512; i++) {
28 threads[i] = new MyThread();
31 for (MyThread thread : threads) {
34 for (MyThread thread : threads) {
38 System.out.println("Thread count: " + MyThread.mCount);
41 System.out.println("thread test done");
44 public static void go() {
45 Thread t = new Thread(null, new ThreadTestSub(), "Thready", 7168);
49 System.out.print("Starting thread '" + t.getName() + "'\n");
54 } catch (InterruptedException ex) {
58 System.out.print("Thread starter returning\n");
62 * Simple thread capacity test.
64 static class MyThread extends Thread {
65 static int mCount = 0;
67 synchronized (MyThread.class) {
74 class ThreadTestSub implements Runnable {
76 System.out.print("@ Thread running\n");
79 Thread.currentThread().setDaemon(true);
80 System.out.print("@ FAILED: setDaemon() succeeded\n");
81 } catch (IllegalThreadStateException itse) {
82 System.out.print("@ Got expected setDaemon exception\n");
86 // throw new NullPointerException();
90 catch (InterruptedException ie) {
91 System.out.print("@ Interrupted!\n");
94 System.out.print("@ Thread bailing\n");