*) last bugfix part. Seems to work now for the stackCrawler

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1478 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent b9c9eaeb44
commit 0fcd113c42

@ -435,24 +435,19 @@ final class CrawlerFactory implements org.apache.commons.pool.PoolableObjectFact
if (obj == null) return;
if (obj instanceof plasmaCrawlWorker) {
plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj;
synchronized(theWorker) {
theWorker.destroyed = true;
theWorker.setName(plasmaCrawlWorker.threadBaseName + "_destroyed");
theWorker.setStopped(true);
theWorker.interrupt();
}
}
}
/**
* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/
public boolean validateObject(Object obj) {
if (obj == null) return false;
if (obj instanceof plasmaCrawlWorker) {
plasmaCrawlWorker theWorker = (plasmaCrawlWorker) obj;
if (!theWorker.isAlive() || theWorker.isInterrupted()) return false;
if (theWorker.isRunning()) return true;
return false;
}
return true;
}

@ -170,11 +170,15 @@ public final class plasmaCrawlWorker extends Thread {
// The thread keeps running.
while (!this.stopped && !this.isInterrupted() && !this.myPool.isClosed) {
if (this.done) {
synchronized (this) {
// return thread back into pool
this.myPool.returnObject(this);
// We are waiting for a new task now.
synchronized (this) { this.wait(); }
if (!this.stopped && !this.destroyed && !this.isInterrupted()) {
this.wait();
}
}
} else {
try {
// executing the new task

@ -716,23 +716,19 @@ public final class serverCore extends serverAbstractThread implements serverThre
public void destroyObject(Object obj) {
if (obj instanceof Session) {
Session theSession = (Session) obj;
synchronized(theSession) {
theSession.destroyed = true;
theSession.setName("Session_destroyed");
theSession.setStopped(true);
theSession.interrupt();
}
}
}
/**
* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/
public boolean validateObject(Object obj) {
if (obj instanceof Session) {
Session theSession = (Session) obj;
if (!theSession.isAlive() || theSession.isInterrupted()) return false;
if (theSession.isRunning()) return true;
return false;
}
return true;
}
@ -934,11 +930,15 @@ public final class serverCore extends serverAbstractThread implements serverThre
// The thread keeps running.
while (!this.stopped && !this.isInterrupted() && !serverCore.this.theSessionPool.isClosed) {
if (this.done) {
synchronized (this) {
// return thread back into pool
serverCore.this.theSessionPool.returnObject(this);
// We are waiting for a new task now.
synchronized (this) {this.wait();}
if (!this.stopped && !this.destroyed && !this.isInterrupted()) {
this.wait();
}
}
} else {
try {
// executing the new task

Loading…
Cancel
Save