FileDocCategorySizeDatePackage
URLPingTask.javaAPI DocExample845Sun Mar 14 15:06:30 GMT 2004javathreads.examples.ch11.example3

URLPingTask

public class URLPingTask extends Object implements Runnable

Fields Summary
URL
url
URLUpdate
uu
Constructors Summary
public URLPingTask(URL url)

        this(url, null);
    
public URLPingTask(URL url, URLUpdate uu)

        this.url = url;
        this.uu = uu;
    
Methods Summary
public voidrun()

        try {
            HttpURLConnection huc = (HttpURLConnection) url.openConnection();
            huc.setConnectTimeout(1000);
            huc.setReadTimeout(1000);
            int code = huc.getResponseCode();
            if (uu != null)
                uu.isAlive(true);
        } catch (Exception e) {
            if (uu != null)
               uu.isAlive(false);
        }