OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [testsuite/] [libjava.lang/] [PR27908.java] - Blame information for rev 765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 765 jeremybenn
class PR27908
2
{
3
  public static void main (String[] argv)
4
    throws InterruptedException
5
  {
6
    run1 r1 = new run1();
7
    run2 r2 = new run2();
8
    run3 r3 = new run3();
9
 
10
    Thread t1, t2, t3;
11
 
12
    (t1 = new Thread (r1)).start();
13
    (t2 = new Thread (r2)).start();
14
    (t3 = new Thread (r3)).start();
15
 
16
    while (! (r1.isRunning() && r2.isRunning() && r3.isRunning()))
17
      Thread.yield();
18
 
19
    r1.stop();
20
    r2.stop();
21
    r3.stop();
22
 
23
    Thread.sleep(5000);
24
 
25
    if (t1.isAlive() || t2.isAlive() || t3.isAlive())
26
      {
27
        System.out.println ("fail");
28
        System.exit(1);
29
      }
30
  }
31
 
32
  private static class run1 implements Runnable
33
  {
34
    volatile int counter;
35
    volatile boolean running;
36
 
37
    public void run ()
38
    {
39
      counter = 0;
40
      running = true;
41
      while (running)
42
        counter++;
43
    }
44
 
45
    void stop ()
46
    {
47
      running = false;
48
    }
49
 
50
    public boolean isRunning()
51
    {
52
      return running;
53
    }
54
  }
55
 
56
  private static class run2 implements Runnable
57
  {
58
    volatile int counter;
59
    boolean running;
60
 
61
    public void run ()
62
    {
63
      counter = 0;
64
      running = true;
65
      while (running)
66
        counter++;
67
    }
68
 
69
    void stop ()
70
    {
71
      running = false;
72
    }
73
 
74
    public boolean isRunning()
75
    {
76
      return running;
77
    }
78
  }
79
 
80
  static class run3 implements Runnable
81
  {
82
    volatile int counter;
83
    private volatile boolean running;
84
 
85
    public void run ()
86
    {
87
      counter = 0;
88
      running = true;
89
      while (running)
90
        counter++;
91
    }
92
 
93
    void stop ()
94
    {
95
      running = false;
96
    }
97
 
98
    public boolean isRunning()
99
    {
100
      return running;
101
    }
102
  }
103
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.