AspectJ does not create threads by itself: the weaving "only" modifies the code by injecting some additional instructions, but it keeps on running in the same context.
The synchronized
keyword on the pointcut definition does not do anything useful. If what you want to achieve is to synchronize all calls (or executions, which would mean less modified code) to methods annotated with @Synchronizes
on the same lock, you need an around advice:
public aspect SynchronizingAspect {
private static final Object lock = new Object();
pointcut syncJointPoint(): execution(@Synchronizes * *.*(..)); // or call()
Object around(): syncJointPoint() {
synchronized(lock) {
return proceed();
}
}
}