turbine-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shane Beasley <sbeas...@acm.org>
Subject Re: Synchronized Velocity Actions
Date Mon, 27 Nov 2006 20:36:14 GMT
Sheldon Ross wrote:

>  public synchronized void doPerform(RunData data, Context context){
>  // do large query
 > return;
 >}

That's the short way to write it. This is a longer way:

public void doPerform(RunData data, Context context){
synchronize (this) {
// do large query
    return;
  }
}

In other words, it requires a lock on the "this" object, which in this 
case is Turbine's system-wide singleton instance of your class. It does 
not consult the method parameters for this purpose.

>  The goal is to have the methods safe for a particular session, but
>  allow multiple sessions to access the methods at the same time.

You want to synchronize your session-level objects. How you do this 
would depend on how you access session data.

You may wish to create a new Session-level tool that handles all 
session-based logic, and then make all its methods synchronized.

Shane

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Mime
View raw message