/core/test/integration/src/Snoozer.java

http://jswat.googlecode.com/ · Java · 71 lines · 24 code · 4 blank · 43 comment · 1 complexity · c2865b0f17e29cda21e90d44c24484f7 MD5 · raw file

  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. * Test code for the thread breakpoint.
  25. *
  26. * @author Nathan Fiedler
  27. */
  28. public class Snoozer {
  29. /**
  30. * @param args the command line arguments
  31. */
  32. public static void main(String[] args) {
  33. Runner r = new Runner();
  34. String[] names = { "a", "ab", "abc", "abcd", "abcde" };
  35. for (String name : names) {
  36. System.out.println("thread " + name + " starting");
  37. Thread th = new Thread(r, name);
  38. th.start();
  39. }
  40. System.out.println("done creating threads");
  41. }
  42. }
  43. /**
  44. * This class is useful for testing that line breakpoints can resolve
  45. * against non-public classes in source files whose names do not match
  46. * the name of the class.
  47. *
  48. * In particular, set a line breakpoint in this code, then close the
  49. * editor window and run the debuggee -- it should stop at the breakpoint
  50. * and open this file.
  51. */
  52. class Runner implements Runnable {
  53. /**
  54. * Sleep for a few seconds and then return.
  55. */
  56. public void run() {
  57. String name = Thread.currentThread().getName();
  58. System.out.println("thread " + name + " running");
  59. long time = (long) Math.random() * 1000;
  60. try {
  61. Thread.sleep(time);
  62. } catch (InterruptedException ie) {
  63. // ignore
  64. }
  65. System.out.println("thread " + name + " done");
  66. }
  67. }