while (!done) {
try {
Thread.sleep(10 * 1000);
System.out.println("Tick");
} catch (InterruptedException unexpected) {
System.out.println("WAHHH!");
done = true;
}
Iterator it = list.iterator();
while (it.hasNext()){
String mesg = ("Your stock price went " +
(rand.nextFloat() > 0.5 ? "up" : "down") + "!");
// Send the alert to the given user.
// If this fails, remove them from the list
try {
((Client)it.next()).alert(mesg);
} catch (RemoteException re) {
System.out.println(
"Exception alerting client, removing it.");
System.out.println(re);
it.remove();
}
}
}