else
{
loader.put(fqn, "k", "v");
}
final int loops = 1000;
final Set exceptions = new CopyOnWriteArraySet();
Thread remover1 = new Thread("Remover-1")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.remove(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
remover1.start();
Thread remover2 = new Thread("Remover-2")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.remove(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), "k");
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
remover2.start();
Thread reader1 = new Thread("Reader-1")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.get(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
reader1.start();
Thread reader2 = new Thread("Reader-2")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.getChildrenNames(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
reader2.start();
Thread writer1 = new Thread("Writer-1")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.put(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), "k", "v");
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
writer1.start();
Thread writer2 = new Thread("Writer-2")
{
public void run()
{
try
{
latch.acquire();
for (int i = 0; i < loops; i++)
{
loader.put(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), new HashMap());
}
}
catch (Exception e)
{
exceptions.add(e);
}
}
};
writer2.start();
latch.release();
reader1.join();
reader2.join();
remover1.join();
remover2.join();
writer1.join();
writer2.join();
Exception e;
for(Iterator it = exceptions.iterator(); it.hasNext();)
{
e = (Exception)it.next();
throw e;
}
}