import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.checkthread.annotations.ThreadSafe;
public class SomeClass {
private final List<String> list = new ArrayList<String>();
private final ReadWriteLock lock = new ReentrantReadWriteLock();
@ThreadSafe
public void add(String obj){
lock.writeLock().lock();
list.add(obj);
lock.writeLock().unlock();
}
}
This should generate a warning that the unlock isn't in a finally:
@ThreadSafe
public void add(String obj){
lock.writeLock().lock();
try {
list.add(obj);
} finally {
lock.writeLock().unlock();
}
}
Original issue reported on code.google.com by pas...@gmail.com on 10 Jan 2011 at 2:41
Original issue reported on code.google.com by
pas...@gmail.com
on 10 Jan 2011 at 2:41