Advertisement
Guest User

Java Code Datentypen

a guest
Oct 14th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. // Klasse1
  2.  
  3. public class Client
  4. {
  5.     protected static boolean isRunning = new Boolean(true); // warum muss das gerade new Boolean (true) heiรŸen?
  6.    
  7.     public static void main(String[] args)
  8.     {
  9.         try
  10.         {
  11.             // Code
  12.             Thread t = new Thread(new CheckThread(client));
  13.             t.start();;
  14.            
  15.             // Code
  16.            
  17.             isRunning = false;
  18.             t.join();
  19.            
  20.             // Code
  21.            
  22.         }
  23.         catch (InterruptedException e) {
  24.             // TODO Auto-generated catch block
  25.             e.printStackTrace();
  26.         }
  27.     }
  28. }
  29.  
  30.  
  31. // Klasse2
  32.  
  33. public class CheckThread implements Runnable
  34. {
  35.     // Code
  36.    
  37.     public void run ()
  38.     {
  39.         try
  40.         {
  41.             // Code
  42.             while (Client.isRunning)
  43.             {
  44.                 // Code
  45.             }
  46.            
  47.             // Code
  48.            
  49.         }
  50.         catch (Exception ex)
  51.         {
  52.             // Code
  53.         }
  54.         finally
  55.         {
  56.             // Code
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement