Exemplo n.º 1
0
  public static void main(String[] args) {
    Hebra h1, h2;
    MiVariable v = new MiVariable(0);
    h1 = new Hebra(v);
    h2 = new Hebra(v);
    h1.thr.start();
    h2.thr.start();

    try {
      h1.thr.join();
      h2.thr.join();
    } catch (InterruptedException ex) {
    }

    System.out.println(v.getValor());
  }
Exemplo n.º 2
0
 public void run() {
   for (int i = 0; i < 20; i++) v.incrementar();
 }