field.set(null, new Long(1));
final CountDownLatch startALatch = new CountDownLatch(1);
final CountDownLatch startBLatch = new CountDownLatch(1);
TestThread threadA = new TestThread("A")
{
public void run()
{
try
{
startBLatch.await();
}
catch (InterruptedException ignored)
{
}
startALatch.countDown();
Class<?> testAbstractFactoryClass = assertLoadClass(TestAbstractFactory.class, a);
try
{
Method method = testAbstractFactoryClass.getMethod("getInstance", (Class[]) null);
method.invoke(null, (Object[]) null);
}
catch (Exception e)
{
throw new Error("Error", e);
}
}
};
TestThread threadB = new TestThread("B")
{
public void run()
{
startBLatch.countDown();
try
{
startALatch.await();
}
catch (InterruptedException ignored)
{
}
assertLoadClass(TestFactoryImplementation.class, b);
}
};
threadA.start();
threadB.start();
threadA.doJoin();
threadB.doJoin();
}
}