Guest User

Untitled

a guest
Nov 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. final class WaitTest {
  2.  
  3. public static void main(String[] args) {
  4. new WaitTest().run();
  5. }
  6.  
  7. void run() {
  8. class Closure {
  9. void call() {
  10. try {
  11. wait(1000);
  12. System.out.println("AHA!");
  13. } catch (InterruptedException e) {
  14. throw new RuntimeException(e);
  15. }
  16. }
  17. }
  18.  
  19. Closure closure = new Closure();
  20. synchronized (this) {
  21. closure.call();
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment