Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package onethread;
  7.  
  8. /**
  9. *
  10. * @author antoniomalevski
  11. */
  12. public class OneThread implements Runnable{
  13. public String a;
  14.  
  15. public OneThread(String a) {
  16. this.a=a;
  17.  
  18. }
  19.  
  20.  
  21. @Override
  22. public void run() {
  23.  
  24. System.out.println(this.a);
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
  31. public static void main(String[] args) {
  32. // TODO code application logic here
  33. OneThread t1=new OneThread("A");
  34. OneThread t2=new OneThread("B");
  35. OneThread t3=new OneThread("1");
  36. OneThread t4=new OneThread("2");
  37. Thread th1=new Thread(t1);
  38. Thread th2=new Thread(t2);
  39. Thread th3=new Thread(t3);
  40. Thread th4=new Thread(t4);
  41. th1.start();
  42. th2.start();
  43. th3.start();
  44. th4.start();
  45.  
  46. }
  47.  
  48.  
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement