Advertisement
Sago

Interface Runnable implementieren

Mar 6th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class Lauffaehig implements Runnable {
  2.    Thread t;
  3.    public Lauffaehig() {
  4.       // Neues Thread Objekt
  5.       t = new Thread(this);
  6.       // Starte Thread
  7.       t.start();
  8.    }
  9. /**
  10.   * Interface Methode run    
  11.   */
  12. public void run() {
  13.    // Endlosschleife
  14.    while(true) {
  15.     // Mache irgendetwas
  16.    try {
  17.        // Warte 200 Millisekunden
  18.        Thread.sleep(200);
  19.    }
  20.    catch(Exception e) {
  21.      // Mache nix
  22.    }
  23.    }
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement