home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / misc / RequestProcessor.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  1.2 KB  |  47 lines

  1. package sun.misc;
  2.  
  3. public class RequestProcessor implements Runnable {
  4.    private static Queue requestQueue;
  5.    private static Thread dispatcher;
  6.  
  7.    public static void postRequest(Request var0) {
  8.       lazyInitialize();
  9.       requestQueue.enqueue(var0);
  10.    }
  11.  
  12.    public void run() {
  13.       lazyInitialize();
  14.  
  15.       while(true) {
  16.          try {
  17.             Object var1 = requestQueue.dequeue();
  18.             if (var1 instanceof Request) {
  19.                Request var2 = (Request)var1;
  20.  
  21.                try {
  22.                   var2.execute();
  23.                } catch (Throwable var3) {
  24.                }
  25.             }
  26.          } catch (InterruptedException var4) {
  27.          }
  28.       }
  29.    }
  30.  
  31.    public static synchronized void startProcessing() {
  32.       if (dispatcher == null) {
  33.          dispatcher = new Thread(new RequestProcessor(), "Request Processor");
  34.          dispatcher.setPriority(7);
  35.          dispatcher.start();
  36.       }
  37.  
  38.    }
  39.  
  40.    private static synchronized void lazyInitialize() {
  41.       if (requestQueue == null) {
  42.          requestQueue = new Queue();
  43.       }
  44.  
  45.    }
  46. }
  47.