Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. class NewThread implements Runnable {
  2. Thread t;
  3. NewThread(){
  4. t = new Thread(this,"My new Thread");
  5. }
  6. }
  7.  
  8. class MyClass implements Runnable {
  9. private final Integer value;
  10.  
  11. MyClass() {
  12. new Thread(this);
  13. int i = 0;
  14. value = Integer.valueOf(20 / i);
  15. }
  16.  
  17. @Override
  18. public void run() {
  19. System.out.println(value.intValue());
  20. }
  21. }
  22.  
  23. class MyClass implements Runnable {
  24. ...
  25. MyClass start() {
  26. new Thread(this);
  27. return this;
  28. }
  29. ...
  30. }
  31.  
  32. // Then construct like this:
  33. MyClass foo = new MyClass().start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement