1 16 package org.apache.commons.collections.buffer; 17 18 import org.apache.commons.collections.Buffer; 19 import org.apache.commons.collections.collection.SynchronizedCollection; 20 21 34 public class SynchronizedBuffer extends SynchronizedCollection implements Buffer { 35 36 37 private static final long serialVersionUID = -6859936183953626253L; 38 39 46 public static Buffer decorate(Buffer buffer) { 47 return new SynchronizedBuffer(buffer); 48 } 49 50 57 protected SynchronizedBuffer(Buffer buffer) { 58 super(buffer); 59 } 60 61 68 protected SynchronizedBuffer(Buffer buffer, Object lock) { 69 super(buffer, lock); 70 } 71 72 77 protected Buffer getBuffer() { 78 return (Buffer) collection; 79 } 80 81 public Object get() { 83 synchronized (lock) { 84 return getBuffer().get(); 85 } 86 } 87 88 public Object remove() { 89 synchronized (lock) { 90 return getBuffer().remove(); 91 } 92 } 93 94 } 95 | Popular Tags |