Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class Test
  2. {
  3.     // this following code won't work in java7!!
  4.     // But works correctly in java8
  5.     public static void main(String[] args)
  6.     {
  7.         /* final */ Object o = new Object() {
  8.             public String toString()
  9.             {
  10.                 return "hello";
  11.             }
  12.         };
  13.         Runnable task1 = new Runnable()
  14.         {
  15.             @Override
  16.             public void run()
  17.             {
  18.                 System.out.println("Task #1 is running " + o);
  19.             }
  20.         };
  21. //      Runnable task2 = () -> { System.out.println("Task #2 is running " + o); };
  22. //      new Thread(task2).start();
  23.         new Thread(task1).start();
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement