Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final class WaitTest {
- public static void main(String[] args) {
- new WaitTest().run();
- }
- void run() {
- class Closure {
- void call() {
- try {
- wait(1000);
- System.out.println("AHA!");
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- }
- }
- Closure closure = new Closure();
- synchronized (this) {
- closure.call();
- }
- }
- }
Add Comment
Please, Sign In to add comment