1 /*
2 * $Id: Main.java,v 1.3 2003/04/02 19:49:00 austvold Exp $
3 * Copyright 2003 OErjan Nygaard Austvold. All rights reserved.
4 */
5
6 package org.jdiseq.dummy;
7
8 import java.util.Random;
9
10 /***
11 * This class implements a simple launcher of a dummy application suitable for observation
12 * from jDiSeq.
13 *
14 * <p>Random calls are made to various no-op methods from a series of threads.</p>
15 *
16 * <p>Changelog:
17 * <pre>
18 * $Log: Main.java,v $
19 * Revision 1.3 2003/04/02 19:49:00 austvold
20 * Minor updates. Mostly adaptation to new event and eventlistener name.
21 * General brush-up on javadoc comments.
22 * Removal of auto-added revision and date-of-commit members.
23 *
24 * Revision 1.2 2003/04/02 19:26:52 austvold
25 * Minor change in random-call setup...
26 *
27 * Revision 1.1.1.1 2003/03/28 08:18:23 austvold
28 * Initial import.
29 *
30 * </pre>
31 *
32 * @author Ørjan Nygaard Austvold <austvold@acm.org>
33 * @version $Id: Main.java,v 1.3 2003/04/02 19:49:00 austvold Exp $
34 */
35 public class Main extends Thread {
36 private static Foo[] foo = new Foo[]{new Foo(), new Foo(), new Foo()};
37 private static Bar[] bar = new Bar[]{new Bar(), new Bar(), new Bar()};
38
39 Main(String name) {
40 super(name);
41 }
42
43 public static void main(String[] args) {
44 int noThreads = 1;
45 for (int i = 0; i < noThreads; i++) {
46 new Main("Dummy thread " + i).start();
47 }
48 }
49
50 public void run() {
51 Random random = new Random();
52 try {
53 while (true) {
54 execute(random);
55 Thread.sleep(500);
56 }
57 } catch (InterruptedException e) {
58 e.printStackTrace();
59 }
60 }
61
62 private void execute(Random random) {
63 int who = random.nextInt(3);
64 if (random.nextBoolean()) {
65 foo[who].execute(random);
66 } else {
67 bar[who].execute(random);
68 }
69 System.err.println();
70 }
71 }
This page was automatically generated by Maven