Chris Pratt wrote:
Using Thread.wait()/Thread.notify() comes to mind.

wait() and notify() are methods of Object, and are what I'm looking for. Thread happens to be a class object and therefore you can call Thread.wait()/Thread.notify() but it probably won't be the synchronization you're looking for.

I think the following patches are the right ones, but beware: while I've confirmed this compiles, I have yet to test it.

+  protected boolean initializationComplete = false;
+  private Object lock = new Object(); // used for synchronization

public OpenSessionBackgroundProcess(String name, ActionInvocation invocation, int threadPriority, SessionFactory factory) {
     super(name, invocation, threadPriority);
     sessionFactory = factory;
+    initializationComplete = true;
+    synchronized (lock) {
+      lock.notify();
+    }
   }

   @Override
   protected void beforeInvocation() throws Exception {
+    while (!initializationComplete) {
+      try {
+        synchronized (lock) {
+          lock.wait(100);
+        }
+      } catch (InterruptedException e) {
+        // behavior ignores cause of re-awakening.
+      }
+    }


-Dale

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@struts.apache.org
For additional commands, e-mail: dev-h...@struts.apache.org

Reply via email to