14. Ejemplo variables estáticas public class CuantaBanco { private String nombre; private int balance; private int Id; private static int proxIdDisponible = 1; /** Constructor, establece nombre dueño y balance inicial de la cuenta */ public CuentaBanco(String nombre, int balance){ this.nombre = nombre; this.balance = balance; this.Id = proxIdDisponible; proxIdDisponible++; }
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34. Creando hebras /** Opción 1 */ import java.lang.*; public class A extends Thread { private: … public A(){…} public void run() { .... } public static void main(String[] args){ A thread1 = new A(); thread1.start(); } } /** Opción 2 */ import java.lang.*; public class B implements Runnable { private: … public B(){…} public void run() { .... } public static void main(String[] args){ B b = new B(); Thread thread1 = new Thread(b); thread1.start(); } }