1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
public class Hilo { public static void main(String[] args){ ThreadB b = new ThreadB(); b.start(); System.out.println("El resultado es: " + b.total); } } class ThreadB extends Thread{ int total; @Override public void run(){ for(int i=0; i<1000 ; i++){ total += i; } } } |