Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

AroundUnlock.java 729B

123456789101112131415161718192021222324252627282930313233
  1. // around advice and unlock
  2. public aspect AroundUnlock {
  3. void around(Foo f): unlock() && args(f) {
  4. System.err.println("around(Foo) lock: advice running at "+thisJoinPoint.getSourceLocation());
  5. proceed(f);
  6. }
  7. void around(): unlock() {
  8. System.err.println("around() lock: advice running at "+thisJoinPoint.getSourceLocation());
  9. proceed();
  10. }
  11. public static void main(String[] args) {
  12. Foo aFoo = new Foo();
  13. aFoo.staticM();
  14. aFoo.nonstaticM();
  15. }
  16. static class Foo {
  17. public void nonstaticM() {
  18. synchronized (this) {
  19. System.err.println("non-static method running");
  20. }
  21. }
  22. public static void staticM() {
  23. synchronized (String.class) {
  24. System.err.println("static method running");
  25. }
  26. }
  27. }
  28. }