diff --git a/src/kademlia/operation/BucketRefreshOperation.java b/src/kademlia/operation/BucketRefreshOperation.java index 5d9e09e..b445bb7 100644 --- a/src/kademlia/operation/BucketRefreshOperation.java +++ b/src/kademlia/operation/BucketRefreshOperation.java @@ -40,12 +40,26 @@ public class BucketRefreshOperation implements Operation for (int i = 1; i < NodeId.ID_LENGTH; i++) { /* Construct a NodeId that is i bits away from the current node Id */ - NodeId current = this.localNode.getNodeId().generateNodeIdByDistance(i); + final NodeId current = this.localNode.getNodeId().generateNodeIdByDistance(i); - // System.out.println("Distance: " + localNode.getNodeId().getDistance(current) + " - ID: " + current); + /* Run the Node Lookup Operation, each in a different thread to speed up things */ + new Thread() + { + @Override + public void run() + { + try + { + System.out.println("Distance: " + localNode.getNodeId().getDistance(current) + " - ID: " + current); - /* Run the Node Lookup Operation */ - new NodeLookupOperation(this.server, this.localNode, this.localNode.getNodeId()).execute(); + new NodeLookupOperation(server, localNode, localNode.getNodeId()).execute(); + } + catch (IOException e) + { + e.printStackTrace(); + } + } + }.start(); } } }