avoid synchronization in DigestURI hash requests

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@7599 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 14 years ago
parent 1989ebc24b
commit 078ecacf61

@ -152,8 +152,11 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
*/ */
public final byte[] hash() { public final byte[] hash() {
// in case that the object was initialized without a known url hash, compute it now // in case that the object was initialized without a known url hash, compute it now
synchronized (this) { if (this.hash == null) {
if (this.hash == null) this.hash = urlHashComputation(); // we check the this.hash value twice to avoid synchronization where possible
synchronized (this) {
if (this.hash == null) this.hash = urlHashComputation();
}
} }
return this.hash; return this.hash;
} }

Loading…
Cancel
Save