1
2
3
4
5
6
7
8
9
10 import java.io.*;
11 import java.awt.*;
12
13 public class HiloAwt extends Frame implements Runnable{
14 TextArea areaTextoPadre;
15 TextArea areaTextoHijo;
16
17 public HiloAwt(){
18 areaTextoPadre = new TextArea();
19 areaTextoHijo = new TextArea();
20 setLayout(new GridLayout(1, 2));
21 add(areaTextoPadre);
22 add(areaTextoHijo);
23 }
24
25 public void imprPadre(){
26 for(;;){
27 areaTextoPadre.setText(areaTextoPadre.getText() + " soy el padre" + "\n");
28 }
29 }
30
31 public void run(){
32 for(;;){
33 areaTextoHijo.setText(areaTextoHijo.getText() +" soy el hijo" + "\n");
34 }
35 }
36 public static void main(String[] argv){
37 HiloAwt hilo = new HiloAwt();
38 Thread h = new Thread(hilo);
39 hilo.show();
40 hilo.setTitle("HiloAwt");
41 h.start();
42 hilo.imprPadre();
43 }
44
45 }
46