import java.awt.*; import java.lang.Math; import java.util.Random; /** A simple applet to illustrate multithreaded programming. It consists of shapes, each running in its own thread that ebb and flow at different rates. @Author: Suresh Srinivasan (suresh@thomtech.com) @Date: Oct 1995 @Version: 0.1 */ public class ShapesApplet extends java.applet.Applet { public int W = 400; public int H = 100; public int N = 15; public final int minSize = 10; public final int maxSize = 50; public final int minNaptime = 1; public final int maxNaptime = 500; public final Color colors[] = { Color.red, Color.pink, Color.orange, Color.yellow, Color.green, Color.magenta, Color.blue, Color.cyan, Color.white, Color.gray, Color.lightGray, Color.darkGray }; public final Color bg = Color.black; boolean threadSuspended = false; Image im; Graphics offscreen; Random rand; Shape shapes[] = new Shape[N]; public void init() { resize(W, H); rand = new Random((long)System.currentTimeMillis()); try { im = createImage(W, H); offscreen = im.getGraphics(); } catch (Exception e) { offscreen = null; } } /* Create each shape with some random parameters and start its thread */ public void start() { for (int i=0; i -->