*) one possible deadlock (because of nested object locks) removed in class kelondroMap

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@61 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent 58a65b60bd
commit 47e426ff7e

@ -128,12 +128,11 @@ public class kelondroMap {
class writeQueue extends Thread { class writeQueue extends Thread {
LinkedList queue; private LinkedList queue = new LinkedList();
boolean run; boolean run;
public writeQueue() { public writeQueue() {
run = true; run = true;
queue = new LinkedList();
} }
public void stack(String key) { public void stack(String key) {
@ -144,20 +143,28 @@ public class kelondroMap {
workoff(key); workoff(key);
} }
public synchronized void workoff() { public void workoff() {
if (queue.size() > 0) workoff((String) queue.removeFirst()); String newKey = null;
synchronized (this.queue) {
if (this.queue.size() > 0) {
newKey = (String) this.queue.removeFirst();
}
}
if (newKey != null) workoff(newKey);
} }
public synchronized void dequeue(String key) { public void dequeue(String key) {
// take out one entry // take out one entry
ListIterator i = queue.listIterator(); synchronized (this.queue) {
String k; ListIterator i = queue.listIterator();
while (i.hasNext()) { String k;
k = (String) i.next(); while (i.hasNext()) {
if (k.equals(key)) { k = (String) i.next();
i.remove(); if (k.equals(key)) {
return; i.remove();
} return;
}
}
} }
} }

Loading…
Cancel
Save