Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] flow of execution in different threads

Hello Serge,

Beaumont, Serge ha scritto:

If you can use static introduction, you have a better alternative. You use
static introduction to attach context information to the argument objects
that get passed from one thread to another. This way you can pass any
information you want across thread borders. Your could for instance
generate a unique number per cflow, and pass that along with your
arguments using static introduction.
fact is that i can use static introduction only knowing "a priori" on which objects i have to introduce stuff...but that's not always the case.

let me try to expose my doubts.

let's say i have this method:

class AsynchronousExecutor implements Runnable {
   Message m;
   AsynchronousExecutor(Message m){this.m = m};
   public void run() {
      //do the stuff
foo(); }
   private foo(){
   //...
   }
}

class ExecutorDispatcher(){

   public void send(Message m){
       AsynchronousExecutor ae = new AsynchronousExecutor(m);
       new Thread(aRunnableObject).start();
   }

}

(i'm considering jdk 5.0 new concurrent stuff, but this shouldn't change anything). now, i want to capture, using something like cflow the execution of foo() method inside the execution of send() method.

if i was in a mono-thread environment, i would do something like that:

public  aspect MultiThread{
pointcut sending(Message m): execution(* AsynchronousExecutor(run()); pointcut multithreadExecutionFlow(Message m): cflow(sending()) && execution (ExecutorDispatcher(send(Message m)));

   before (Message m): multithreadExecutionFlow(Message m){
      //HERE IS MY DOUBT: I WANT TO INTRODUCE INFO ABOUT THE
       //CURRENT FLOW OF EXECUTION ONLY AT THIS POINT
      //and not in every istance of the class Message
}
}


i hope to have clarified my doubts.

thanks,
Valerio







Back to the top