home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / samples.z / URLPollingThread.java < prev    next >
Text File  |  1996-12-16  |  2KB  |  83 lines

  1. /*
  2.  * URLList.java
  3.  *
  4.  *
  5.  * Copyright 1996 Sybase, Inc. All rights reserved.
  6.  */
  7.  
  8.  
  9. /**
  10.  * URLPollingThread is a thread that will forever sleep for a
  11.  * specified interval, wake up, poll a list of URLs.
  12.  */
  13.  
  14. public class URLPollingThread extends Thread
  15. //******************************************
  16. {
  17.     
  18.     //-------------------------------------------------------------
  19.     // Public Methods
  20.     //-------------------------------------------------------------
  21.     
  22.     /**
  23.      * Sets the URL list for this thread
  24.      * @param aList URL list
  25.      */
  26.      
  27.     public void setURLList( URLList aList )
  28.     //*************************************
  29.     {
  30.         _list = aList;
  31.     }
  32.     
  33.     public synchronized void run()
  34.     //****************************
  35.     {
  36.         try {                    
  37.            for( ;; ) {
  38.                 // Sleep for the specified interval. Then wake up 
  39.                 // and poll the current list of URLs to see if
  40.                 // they've been modified since went to sleep
  41.                 sleep( _sleepTime );                           
  42.                 _list.pollURLs();
  43.            }
  44.             
  45.         } catch( InterruptedException e ) {
  46.         }
  47.     }
  48.     
  49.     
  50.     //-------------------------------------------------------------
  51.     // Properties
  52.     //-------------------------------------------------------------
  53.     
  54.     
  55.     /**
  56.      * Returns the poll (sleep) interval
  57.      */
  58.      
  59.     public long getSleepTime()
  60.     //************************
  61.     {
  62.         return _sleepTime;
  63.     }
  64.     
  65.     /**
  66.      * Sets the poll (sleep) interval
  67.      */
  68.      
  69.     public void setSleepTime( long sTime )
  70.     //************************************
  71.     {
  72.         _sleepTime = sTime;
  73.     }
  74.     
  75.     //-------------------------------------------------------------
  76.     // Data
  77.     //-------------------------------------------------------------
  78.     
  79.     static private URLList _list = null;
  80.     static private long _sleepTime = 60000;
  81.     
  82. }
  83.