Limited synchronized association access
This commit is contained in:
parent
c755b57e0c
commit
dcc5b44520
@ -104,4 +104,8 @@ public interface Association<T, U> {
|
||||
static <T, U> Association<T, U> synchronize(Association<T, U> association) {
|
||||
return new SynchronizedAssociation(association);
|
||||
}
|
||||
|
||||
static <T, U> Association<T, U> synchronize(Association<T, U> association, Object lock) {
|
||||
return new SynchronizedAssociation(association, lock);
|
||||
}
|
||||
}
|
||||
|
@ -103,4 +103,8 @@ public interface BiAssociation<T, U> {
|
||||
static <T, U> BiAssociation<T, U> synchronize(BiAssociation<T, U> association) {
|
||||
return new SynchronizedBiAssociation(association);
|
||||
}
|
||||
|
||||
static <T, U> BiAssociation<T, U> synchronize(BiAssociation<T, U> association, Object lock) {
|
||||
return new SynchronizedBiAssociation(association, lock);
|
||||
}
|
||||
}
|
||||
|
@ -3,17 +3,17 @@ package org.warp.commonutils.type;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class SynchronizedAssociation<T, U> implements Association<T, U> {
|
||||
public final class SynchronizedAssociation<T, U> implements Association<T, U> {
|
||||
|
||||
private final Association<T,U> association;
|
||||
private final Object lock;
|
||||
|
||||
public SynchronizedAssociation(Association<T, U> association) {
|
||||
SynchronizedAssociation(Association<T, U> association) {
|
||||
this.association = association;
|
||||
this.lock = new Object();
|
||||
}
|
||||
|
||||
public SynchronizedAssociation(Association<T, U> association, Object lock) {
|
||||
SynchronizedAssociation(Association<T, U> association, Object lock) {
|
||||
this.association = association;
|
||||
this.lock = lock;
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ package org.warp.commonutils.type;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class SynchronizedBiAssociation<T, U> implements BiAssociation<T, U> {
|
||||
public final class SynchronizedBiAssociation<T, U> implements BiAssociation<T, U> {
|
||||
|
||||
private final BiAssociation<T,U> association;
|
||||
private final Object lock;
|
||||
|
||||
public SynchronizedBiAssociation(BiAssociation<T, U> association) {
|
||||
SynchronizedBiAssociation(BiAssociation<T, U> association) {
|
||||
this.association = association;
|
||||
this.lock = new Object();
|
||||
}
|
||||
|
||||
public SynchronizedBiAssociation(BiAssociation<T, U> association, Object lock) {
|
||||
SynchronizedBiAssociation(BiAssociation<T, U> association, Object lock) {
|
||||
this.association = association;
|
||||
this.lock = lock;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user