+ /** an InputStream that makes sure it is not in the MessageQueue when blocked on a read */
+ // FIXME
+ private static class BackgroundInputStream extends FilterInputStream {
+ BackgroundInputStream(InputStream i) { super(i); }
+ /*
+ private void suspend() throws IOException {
+ if (!ThreadMessage.suspendThread())
+ throw new IOException("attempt to perform background-only operation in a foreground thread");
+ }
+ private void resume() {
+ ThreadMessage.resumeThread();
+ }
+ public int read() throws IOException {
+ suspend();
+ try { return super.read(); }
+ finally { resume(); }
+ }
+ public int read(byte[] b, int off, int len) throws IOException {
+ suspend();
+ try { return super.read(b, off, len); }
+ finally { resume(); }
+ }
+ */
+ }
+