0

嗨,我正在尝试测试代理,但如果我将 setConnectTimeout 设置为超过 1500,它会导致程序挂起,它只会死,什么都不会打印我的处理器和内存,它做的很多,它就死了,有人知道解决方案吗?代码是
HttpURLConnection inSite = (HttpURLConnection) site.openConnection(代理);
inSite.setConnectTimeout(2000); //如果设置在1500以下就可以了

这是一个真正的问题,因为大多数代理此时响应速度太慢,谢谢

4

1 回答 1

0

private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);

public void sixtymin() {

    final Runnable logger= new Runnable() {//instansiation

        @Override
        public void run() {
            System.out.println(System.currentTimeMillis());//code to execute
        }
            //You application logic as shown in the question
        };
    final ScheduledFuture<?> loggerHandle =
        scheduler.scheduleAtFixedRate(logger, 0, 5, SECONDS );//action,delay before first run,delay between,unit

这是解决方案上面的代码每5秒打印一次,所以我用它来终止进程超时

于 2013-06-07T11:16:55.573 回答