public static Boolean timeOutIsLogin(Integer times,String ip, String userName, String userPwd) {
Boolean obj = false;
final ExecutorService exec = Executors.newFixedThreadPool(1);
Callable<Boolean> call = new Callable<Boolean>() {
public Boolean call() throws Exception {
return ShellUtil.isLogin( ip, userName, userPwd) ;
}
};
//10秒后退出
try {
Future<Boolean> future = exec.submit(call);
obj = future.get(times * 1500, TimeUnit.MILLISECONDS); // 任务处理超时时间设为10秒
return obj;
} catch (Exception e) {
return false;
}
}