+ public void qcmd(String... tokens) {
+ qcmd(new Command(tokens));
+ }
+
+ public Response ecmd(Command cmd) throws ClosedException, InterruptedException {
+ checkthread();
+ final boolean[] donep = new boolean[] {false};
+ final Response[] resp = new Response[] {null};
+ final Exception[] errp = new Exception[] {null};
+ Object l = cmd.new Listener() {
+ public synchronized void done(Response rsp) {
+ resp[0] = rsp;
+ donep[0] = true;
+ notifyAll();
+ }
+
+ public synchronized void error(Exception e) {
+ errp[0] = e;
+ donep[0] = true;
+ notifyAll();
+ }
+ };
+ synchronized(l) {
+ while(!donep[0]) {
+ l.wait();
+ }
+ }
+ if(errp[0] != null)
+ throw(new ClosedException(errp[0]));
+ return(resp[0]);
+ }
+
+ public Response ecmd(String... tokens) throws ClosedException, InterruptedException {
+ return(ecmd(new Command(tokens)));
+ }
+