Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
Fixed PoolSearch shutting down method
Browse files Browse the repository at this point in the history
  • Loading branch information
rdadkins committed May 14, 2016
1 parent 73720b6 commit 5274cd4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public void onQueryAdded(RegexQuery query) {
private void searchAll() {
ECKey key;
RegexQuery query;
long localGen = 0;
while (!forceStop) {
long localGen;
while (!(forceStop || threadKilled())) {
key = new ECKey();
localGen = ++generated;
if ((query = pool.matches(key, netParams)) != null) {
Expand All @@ -129,7 +129,7 @@ private void searchInOrder() {
ECKey key;
long localGen;
isSearching = true;
while (isSearching) {
while (isSearching && !threadKilled()) {
key = new ECKey();
localGen = ++generated;
if (query.matches(key, netParams)) {
Expand Down Expand Up @@ -162,6 +162,10 @@ private RegexQuery getNextQuery() {
return query;
}

private boolean threadKilled() {
return Thread.currentThread().isInterrupted();
}

public void stop() {
forceStop = true;
isSearching = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public void maxSpeed(int threads) {
} catch (InterruptedException e) {
e.printStackTrace();
}
for (Runnable thread: service.shutdownNow()) {
PoolSearch search = (PoolSearch) thread;
search.stop();
}
service.shutdownNow();
System.out.println("Max Speed: " + listener.maxSearchSpeed);
}

Expand Down

0 comments on commit 5274cd4

Please sign in to comment.