Advertisement
ivanakarpuzova

lab2zad1DopolnitelnoBaranje

Mar 28th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. package com.company;
  2.  
  3. class TwoThreads {
  4. public static class ThreadAB implements Runnable {
  5. private String[] niza;
  6.  
  7. public ThreadAB(String[] niza) {
  8. this.niza = niza;
  9.  
  10. }
  11.  
  12. public void run() {
  13. for(int i = 0; i < niza.length; i++){
  14. System.out.println(niza[i]);
  15. }
  16. }
  17. }
  18.  
  19. public static void main(String[] args) {
  20. ThreadAB ab = new ThreadAB(new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"});
  21. Thread t1=new Thread(ab);
  22. t1.start();
  23.  
  24. String[] brojkiNiza = new String[27];
  25. for(int i = 0; i <= 26; i++){
  26. brojkiNiza[i] = i + "";
  27. }
  28. ThreadAB brojki = new ThreadAB(brojkiNiza);
  29. Thread t2 = new Thread(brojki);
  30. t2.start();
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement