Guest User

Untitled

a guest
Dec 10th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public class Test
  2. {
  3.   public static void main(String[] args)
  4.   {
  5.     Runnable runnable = getRunnable();
  6.    
  7.     Thread thread = new Thread(runnable);
  8.    
  9.     thread.start();
  10.    
  11.   }
  12.  
  13.   public static Runnable getRunnable()
  14.   {
  15.     class IntPair
  16.     {
  17.       int a;
  18.       int b;
  19.      
  20.       public int sum()
  21.       {
  22.         return this.a+this.b;
  23.       }
  24.     }
  25.    
  26.     final IntPair p = new IntPair();
  27.     p.a = 10;
  28.     p.b = 17;
  29.    
  30.     Runnable runnable = new Runnable()
  31.       {
  32.         class AnotherIntPair
  33.         {
  34.           int a;
  35.           int b;
  36.         }
  37.      
  38.         public void run()
  39.         {
  40.           /*while(true)
  41.           {*/
  42.             System.out.println(p.sum());
  43.           /*  try
  44.             {
  45.             Thread.sleep(1000);
  46.             }
  47.             catch(Exception e)
  48.             {
  49.               return;
  50.             }
  51.           }*/
  52.         }
  53.       };
  54.      
  55.     return runnable;
  56.   }
  57. }
Add Comment
Please, Sign In to add comment