Threads can share data in memory
The Spider class does all the work, one step at a time
Imagine yourself as a spider working with a group of others
These operations must be atomic: only one thread can be executing this operation at a time
Which operations on the work data structure should be atomic?
public interface Runnable {
abstract public void run();
}
In our case, this is called ConcurrentSpider
Speedup is a number we can compute by running experiments. It gives us an indication of how much faster our threaded version is than our original ‘sequential’ version with one Spider.
We measure speedup by taking the time to run the original non-threaded version and dividing it by the time to run the threaded version. If when using 2 threads on the same number of URLS the code takes half the amount of time, we would have perfect speedup of 2. This rarely happens, and we expect our speedup to be less than perfect due to some amount of overhead incurred when running threads that are updating shared data structures.
Dig Deeper:
Once you’ve implemented your solution,