public abstract class ACrawler
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
protected java.util.List<ACrawler> |
crawlers
Child crawler objects stored here.
|
protected ThreadScheduler |
sched
Thread count limiter, used by scheduleCrawlers().
|
protected long |
time
Crawl time in nanoseconds.
|
Constructor and Description |
---|
ACrawler() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
crawl()
This method should implement the crawler algorhytm.
|
long |
getTime() |
void |
interrupt()
Interrupts all child threads and the scheduler too.
|
void |
launch(boolean asNewThread)
Starts the crawler algorhytm.
|
void |
run()
Calls crawl(), and measures running time in 'time' field.
|
protected void |
scheduleCrawlers(int threadLimit)
Schedules the child crawler threads: starts them in order, and provides
that the maximum count of running threads will be threadLimit.
|
protected void |
waitForCrawlers()
Waits for the child crawler threads (stored in 'crawlers' field) to stop.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected java.util.List<ACrawler> crawlers
protected ThreadScheduler sched
protected long time
protected abstract void crawl()
public long getTime()
public void interrupt()
interrupt
in class java.lang.Thread
public void launch(boolean asNewThread)
asNewThread
- if true, it calls start(), otherwise it calls run().public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
protected void scheduleCrawlers(int threadLimit)
threadLimit
- The maximum count of running child crawler threads.protected void waitForCrawlers()