Re: Findbugs and locks?
- From: Jeff Higgins <oohiggins@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 09:28:54 -0400
Oops.
Still no bug reports.
import java.io.IOException;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
public class SSCCE {
static ReentrantReadWriteLock lockArray[];
static {
lockArray =
new ReentrantReadWriteLock[5];
for (int i=0; i<lockArray.length; i++)
lockArray[i] = new ReentrantReadWriteLock();
}
static void method(int n) throws IOException {
if (n < lockArray.length) {
WriteLock lock = lockArray[n].writeLock();
try {
lock.lock();
// do some disk I/O
} finally {
lock.unlock();
}
}
}
public static void main(String[] args) {
}
}
.
- References:
- Findbugs and locks?
- From: Knute Johnson
- Re: Findbugs and locks?
- From: Jeff Higgins
- Findbugs and locks?
- Prev by Date: Re: Findbugs and locks?
- Next by Date: Java Interview Question bank
- Previous by thread: Re: Findbugs and locks?
- Next by thread: Re: Findbugs and locks?
- Index(es):