Subject: sw409 lecture 9/6/00
import java.util.*;
import java.awt.*;
public class DougException
extends RuntimeException {
public DougException(String s) {
super(s);
}
public DougException() {
}
}
public class Counters {
static Thread ta[] = new Thread[100];
public static void main(String args[]) {
for(int i = 0;i < ta.length;i++) {
ta[i] = new Thread(new Counter());
ta[i].start();
}
}
}
public class Counter implements Runnable {
//Thread t = new Thread(this);
private int i =0;
public static void main(String args[]) {
Counter c = new Counter();
//c.t.start();
}
public void run() {
for (int i=0; i < 10; i++)
System.out.println(i);
}
}
public class TrivialApplication extends Frame
{
static Vector customerNames
= new Vector();
private static int m = 0;
synchronized public void setM(int _m) {
m = _m;
}
public void init() {
setSize(200,200);
setVisible(true);
}
synchronized public void paint(Graphics g) {
g.drawString("Hello World!"+ m++,
100,100);
repaint(1000);
}
public static void main(String args[]) {
TrivialApplication
f = new TrivialApplication();
f.init();
}
public static void exceptionalExample(
String args[]) {
System.out.println(
"Hello World!" );
customerNames.add("Tom");
customerNames.add("Dick");
customerNames.add("Harry");
customerNames.add(
new DougException("Hello World!"));
for (int i = 0;
i < customerNames.size();
i++) {
System.out.println(
customerNames.elementAt(i));
}
//try {
// int i = 1/ 0;
//}
//catch (
// ArithmeticException e) {
// ha ha arian 4 blows up!!
//}
}
}