HILOS EN JFRAME DE JAVA
DEFINICIÓN DE JFRAME public class NewJFrame extends javax.swing.JFrame implements Runnable { Thread h1, h2; ... MÉTODO RUN EN EL JFRAME public void run() { for (int i = 0; i < 5 ; i++){ Thread ct = Thread.currentThread(); if(ct == h1) { System.out.println(i + " h1 " + Thread.currentThread().getName()); } if(ct == h2) { System.out.println(i + " h2 " + Thread.currentThread().getName()); } try { Thread.sleep(1000); }catch(InterruptedException e) {} } System.out.println("Termina thread " + Thread.currentThread().getName()); } ACTIVACIÓN DE HILOS //Puede ser activado al implementar el jframe o un control como un jbutton h1 = new Thread(this); h2 = new Thread(this); this.h1.start(); this.h2.start();