/core/test/integration/src/Snoozer.java
Java | 71 lines | 24 code | 4 blank | 43 comment | 1 complexity | c2865b0f17e29cda21e90d44c24484f7 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
1/* 2 * The contents of this file are subject to the terms of the Common Development 3 * and Distribution License (the License). You may not use this file except in 4 * compliance with the License. 5 * 6 * You can obtain a copy of the License at http://www.netbeans.org/cddl.html 7 * or http://www.netbeans.org/cddl.txt. 8 * 9 * When distributing Covered Code, include this CDDL Header Notice in each file 10 * and include the License file at http://www.netbeans.org/cddl.txt. 11 * If applicable, add the following below the CDDL Header, with the fields 12 * enclosed by brackets [] replaced by your own identifying information: 13 * "Portions Copyrighted [year] [name of copyright owner]" 14 * 15 * The Original Software is JSwat. The Initial Developer of the Original 16 * Software is Nathan L. Fiedler. Portions created by Nathan L. Fiedler 17 * are Copyright (C) 2005. All Rights Reserved. 18 * 19 * Contributor(s): Nathan L. Fiedler. 20 * 21 * $Id: Snoozer.java 40 2009-01-09 07:35:28Z nathanfiedler $ 22 */ 23 24/** 25 * Test code for the thread breakpoint. 26 * 27 * @author Nathan Fiedler 28 */ 29public class Snoozer { 30 31 /** 32 * @param args the command line arguments 33 */ 34 public static void main(String[] args) { 35 Runner r = new Runner(); 36 String[] names = { "a", "ab", "abc", "abcd", "abcde" }; 37 for (String name : names) { 38 System.out.println("thread " + name + " starting"); 39 Thread th = new Thread(r, name); 40 th.start(); 41 } 42 System.out.println("done creating threads"); 43 } 44} 45 46/** 47 * This class is useful for testing that line breakpoints can resolve 48 * against non-public classes in source files whose names do not match 49 * the name of the class. 50 * 51 * In particular, set a line breakpoint in this code, then close the 52 * editor window and run the debuggee -- it should stop at the breakpoint 53 * and open this file. 54 */ 55class Runner implements Runnable { 56 57 /** 58 * Sleep for a few seconds and then return. 59 */ 60 public void run() { 61 String name = Thread.currentThread().getName(); 62 System.out.println("thread " + name + " running"); 63 long time = (long) Math.random() * 1000; 64 try { 65 Thread.sleep(time); 66 } catch (InterruptedException ie) { 67 // ignore 68 } 69 System.out.println("thread " + name + " done"); 70 } 71}