Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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 programparalel;
  7.  
  8. /**
  9. *
  10. * @author 6530729
  11. */
  12. public class ProgramParalel extends Thread{
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17.  
  18. static int x = 0;
  19.  
  20.  
  21. public void run(){
  22. for(int i = 0;i<999;i++){
  23. this.x++;
  24. }
  25. }
  26.  
  27. public static void main(String[] args) {
  28.  
  29.  
  30. //Operacao t1 = new Operacao();
  31. //t1.start();
  32. ProgramParalel t1 = new ProgramParalel();
  33. t1.start();
  34. ProgramParalel t2 = new ProgramParalel();
  35. t2.start();
  36. ProgramParalel t3 = new ProgramParalel();
  37. t3.start();
  38.  
  39. try{
  40. t1.join();
  41. t2.join();
  42. t3.join();
  43.  
  44. }catch(Exception e){
  45. System.out.print("Não foi possivel");
  46. }
  47.  
  48. System.out.print(x);
  49.  
  50.  
  51. }
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement