Hi i have a code to check a proxy. I always get false when I run the method. I understand that the problem is the last false. When I output it on the console with println, it also differs between false and true but does not return the correct one as the return value of the method. Can you help please! If the proxy is online, the code must output true
final ExecutorService es = Executors.newFixedThreadPool(100);
public boolean isProxyOnline(String proxyIp, int proxyPort) {
es.submit(() -> {
try {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyIp, proxyPort));
URLConnection connection = new URL("http://www.google.com").openConnection(proxy);
connection.setConnectTimeout(1000);
connection.connect();
System.out.println("true");
return true;
} catch (Exception e) {
System.out.println("false");
return false;
}
});
return false;
}