Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class Proxies extends System<Proxies> implements Iterable<Proxy> {
.name("threads")
.description("The number of concurrent threads to check proxies with.")
.defaultValue(8)
.min(0)
.sliderRange(0, 32)
.min(1)
.sliderRange(1, 32)
.build()
);

Expand Down Expand Up @@ -150,12 +150,7 @@ public void checkProxies(boolean all) {

try (ExecutorService executor = Executors.newFixedThreadPool(threads.get())) {
for (int i = 0; i < threads.get(); i++) {
executor.execute(() -> {
try {
check(toCheck, checked);
} catch (InterruptedException _) {
}
});
executor.execute(() -> check(toCheck, checked));
}

try {
Expand All @@ -164,18 +159,19 @@ public void checkProxies(boolean all) {
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (InterruptedException _) {
}

} finally {
refreshing = false;
}
});
}

private void check(BlockingQueue<Proxy> queue, ConcurrentHashMap<Proxy, Integer> checks) throws InterruptedException {
while (!queue.isEmpty()) {
Proxy proxy = queue.take();
private void check(BlockingQueue<Proxy> queue, ConcurrentHashMap<Proxy, Integer> checks) {
Proxy proxy;

while ((proxy = queue.poll()) != null) {
if (proxy.checkStatus() == 3 && checks.get(proxy) <= tries.get()) {
checks.put(proxy, checks.get(proxy) + 1);
queue.put(proxy);
queue.offer(proxy);
}
}
}
Expand Down