Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

AfterUnlock.java 690B

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