
public void testAction() {
	Runnable r = new Runnable() {
	    public void run() {
		int i = 0;
		while (true) {
		    EOEditingContext ec = new EOEditingContext();
		    try {
			ec.lock();
			NSArray eos = EOUtilities.objectsForEntityNamed(ec, "TestEntity");
			Enumeration enumeration = eos.objectEnumerator();
			while (enumeration.hasMoreElements()) {
			    TestEntity testEntity = (TestEntity) enumeration.nextElement();
			    testEntity.setTestValue(Thread.currentThread().getName() + "/" + (i++));
			    ec.saveChanges();
			    if ((i % 1000) == 0) {
				System.out.println(Thread.currentThread().getName() + " still running after " + i + " iterations.");
			    }
			}
		    } catch (Exception e) {
			e.printStackTrace();
		    } finally {
			ec.unlock();
			ec.dispose();
		    }
		}
	    }
	};

	new Thread(r).start();
}


public void cleanupAction() {
	Runnable r = new Runnable() {
	    public void run() {
		while (true) {
		    try {
			Thread.sleep((long) (Math.random() * 5000));
		    } catch (InterruptedException e) {
		    }

		    EOEditingContext ec = new EOEditingContext();
		    try {
			ec.lock();
			ec.rootObjectStore().lock();
			System.out.println("cleanup time");
			// simulate change notification
			ec.rootObjectStore().invalidateAllObjects();
		    } finally {
			ec.rootObjectStore().unlock();
			ec.unlock();
			ec.dispose();
		    }
		}
	    }
	};

	new Thread(r).start();
}
