if (args.length > ++k) config.setMaxLifeTime(Long.parseLong(args[k]));
int printStep = 10;
if (args.length > ++k) printStep = Math.max(1, Integer.parseInt(args[k]));
final DocumentMap pool = new DocumentMap(config);
for (int j=0; j < threads; j++) {
final int t = j;
final Document xmlDoc = doc;
final int step = printStep;
Runnable runner = new Runnable() {
public void run() {
try {
int i = 0;
while (true) {
if (i % step == 0) System.out.println("t="+ t + ", index=" + i);
Document doc;
if (xmlDoc == null) {
Element root = new Element("root");
Element child = new Element("child");
root.appendChild(child);
for (int j=0; j < 10000; j++) child.appendChild("xxxxxxxxxxxxxxxxxx" + j);
doc = new Document(root);
}
else {
doc = xmlDoc;
if (config.getCompressionLevel() == -1) doc = new Document(doc);
}
Object key = new Integer(i + t*100);
// Object key = new Integer(-1);
pool.putDocument(key, doc);
// // simulate hot cache items (gc should bias against collecting these)
pool.getDocument(new Integer(8));
// pool.getDocument(key);
i++;
}
}