Hi,

>[Robert Harper]
>I still need to know how I am to wait without burning the CPU while I
am
>waiting
>for a response. I would rather not have to have the web page have to
keep
>checking back for a response.

It's been a while since I've had to post code on here ;)  Here's a
generic way to spawn a thread and only check on it every X milliseconds,
instead of all the time, so that you don't "burn the CPU:"

class MyServlet extends HttpServlet {
  ...
  ...doGet(...) {
    Thread myThread = new MyThread();
    while(! (myThread.isDone())) {
      Thread.currentThread().sleep(5000);
    }
    myThread = null;

    ...
  }
}

class MyThread extends Thread() {
  ...
  boolean done = false;

  MyThread() {
    ...
    setDaemon(true);
  }

  run() {
    ...
    done = true;
  }

  boolean isDone() {
    return done;
  }
}

That's it.  I omitted accessors and such for brevity, but I hope you get
the point of this approach.  As I said previously, this is still
inferior, both from a cleanliness/maintainability and from a
Spec-compliance point of view, to a design-based solution like JMS.  But
it'll work, so hopefully now I've given enough detail for you.

Yoav




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to