I am using Spring AOP in my code to intercept the execution of a certain method. A simplified example of what I'm trying to do is below:
public void someMethod() {
//does something
}
@Around("execution( someMethod())")
public void anotherMethod(final ProceedingJoinPoint joinPoint) {
//i want to add this to a queue to get executed later on
addToWaitList(new Callable() {
@Override
public call() throws Exception {
joinPoint.proceed();
}
});
return;
}
Essentially, I want to hold off the execution of someMethod() until it is at the head of the list. However, the main thread blocks, even though I return at the end of anotherMethod(), so I am unable to add a new Callable to the list until the first one is done executing.