Does anybody have a good
test harness to test the lock/unlock sequence. What excatly are we looking for in the test? Is it that for every
thread that goes into a wait mode, it must eventually get a lock otherwise its deadlocked. I wrote a simple test harness. There are five threads but some of the threads are getting deadlocked meaning, they never acquire a lock.
public class LockTesting extends Thread {
private static Data data1;
private static Data data2;
public static void main(
String[] args) {
data1 = new Data(); //Is two data Data objects valid
// data2 = new Data();
LockTesting test1 = new LockTesting();
LockTesting test2 = new LockTesting();
LockTesting test3 = new LockTesting();
LockTesting test4 = new LockTesting();
LockTesting test5 = new LockTesting();
test1.start();
test2.start();
test3.start();
test4.start();
test5.start();
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
long cookie1 = data1.lockRecord(1);
data1.updateRecord(1, null, cookie1);
}
}