import java.applet.Applet; import java.awt.*; public class Poets extends Applet { public void init() { TextArea display = new TextArea("", 10, 30, TextArea.SCROLLBARS_VERTICAL_ONLY); add(display); Nursery nursery = new Nursery(display); Revolutionary revolutionary = new Revolutionary(display); nursery.start(); revolutionary.start(); } } class Nursery extends Thread { private TextArea display; public Nursery(TextArea display) { this.display = display; } public void run() { while (true) { display.append("Mary had a little lamb\n"); display.append("Its fleece was white as snow\n\n"); try { Thread.sleep(5000); } catch (InterruptedException e) { display.append ("sleep exception - design fault\n"); } } } } class Revolutionary extends Thread { private TextArea display; public Revolutionary(TextArea display) { this.display = display; } public void run() { while (true) { display.append("Praise Marx\n"); display.append("and pass the ammunition\n\n"); try { Thread.sleep(5000); } catch (InterruptedException e) { display.append ("sleep exception - design fault\n"); } } } }