wieruowq

FileService.java

Jun 8th, 2017
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. import java.awt.List;
  3. import java.util.*;
  4. import java.net.*;
  5. import java.io.*;
  6. class FileService extends Thread
  7. {
  8. public LinkedList<String> list1 = new LinkedList<String>();
  9. public List list;
  10. public String[] listOfNames = new String[10];
  11.  
  12. public FileService(List list)
  13. {
  14. this.list = list;
  15. }
  16.  
  17. public void run()
  18. {
  19. try
  20. {
  21. while (true)
  22. {
  23. synchronized (list1)
  24. {
  25. if (!list1.isEmpty())
  26. {
  27. String s = list1.remove(0);
  28. System.out.println(this + " was empty so we removed it " + s);
  29. }
  30. else
  31. {
  32. list1.wait(1000);
  33. }
  34. }
  35. }
  36. }
  37. catch (InterruptedException e) {
  38. }
  39. }
  40. }
  41.  
  42. class Main
  43. {
  44. public static void main(String[] args)
  45. {
  46.  
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment