I posted this a few day ago on Newbie. No response so posting here....
Does anyone know a simple way to serialize key events?
A Java prog. friend suggested using a "Mailbox" class to serialize the key
input and provided a class (below) but I don't really understand java Vectors.
Ideas?
thanks very much!
import java.util.*;
public class Mailbox {
private int numMessages = 0;
private Vector mailbox = new Vector();
public synchronized void insert(Object obj) {
mailbox.addElement(obj);
numMessages++;
notify();
}
public synchronized Object remove() {
while (numMessages == 0) {
try {
wait();
} catch (Exception e) {
}
}
Object obj = mailbox.firstElement();
mailbox.removeElementAt(0);
numMessages--;
return obj;
}
public synchronized int numobj() {
return numMessages;
}
public synchronized Vector flush() {
Vector vector = null;
if (numMessages > 0)
vector = new Vector();
while (numMessages > 0) {
Object obj = mailbox.firstElement();
vector.addElement(obj);
mailbox.removeElementAt(0);
numMessages--;
}
return vector;
}
}
---------------------------------
Yahoo! Mail goes everywhere you do. Get it on your phone.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com