Advertisement
Guest User

Untitled

a guest
May 27th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. import java.util.concurrent.ArrayBlockingQueue;
  2. import java.util.concurrent.BlockingQueue;
  3.  
  4. public class Main{
  5.  
  6. public static void main(String[] args) {
  7. BlockingQueue<Integer> queueOut = new ArrayBlockingQueue<>(20);
  8. BlockingQueue<Integer> queueIn = new ArrayBlockingQueue<>(20);
  9.  
  10.  
  11. Empfaenger empfaenger= new Empfaenger(queueIn, queueOut);
  12. System.out.println("main,queuein: "+queueIn);
  13. System.out.println("main,queueout: "+queueOut);
  14. Sender sender=new Sender(queueIn,queueOut);
  15.  
  16. while(true) {
  17. Thread t1 = new Thread(empfaenger.e1);
  18. //Thread t2 = new Thread(sender.s1);
  19. t1.start();
  20. //t2.start();
  21. }
  22. }
  23. }
  24.  
  25.  
  26.  
  27.  
  28. import com.google.gson.Gson;
  29.  
  30. import java.util.concurrent.BlockingQueue;
  31.  
  32. public class Empfaenger{
  33. private BlockingQueue<Integer> queueIn;
  34. private BlockingQueue<Integer> queueOut;
  35.  
  36. static private Gson gson=new Gson();
  37.  
  38. public Empfaenger(BlockingQueue<Integer> queueIn, BlockingQueue<Integer> queueOut) {
  39. this.queueIn=queueIn;
  40. this.queueOut=queueOut;
  41. }
  42. public Runnable e1 =new Runnable(){
  43. @Override
  44. public void run() {
  45. try{
  46. queueOut.offer(readConsole());
  47. //readFile();
  48. //readTCP();
  49. //readUDP();
  50. System.out.println("empf,queuein: "+queueIn);
  51. System.out.println("empf,queueout: "+queueOut);
  52. }catch(Exception exp){exp.printStackTrace();}
  53. }};
  54.  
  55. private int readConsole() {
  56. System.out.println("zahl: ");
  57. int nachricht= scan.nextInt();
  58. return modify(nachricht);
  59. }
  60.  
  61. private void readFile() {
  62. }
  63.  
  64. private void readTCP() {
  65. }
  66.  
  67. private void readUDP() {
  68. }
  69.  
  70.  
  71. private int modify(int a){
  72. return a++;
  73. }
  74.  
  75. public BlockingQueue<Integer>getqueuein(){
  76. return queueIn;
  77. }
  78. }
  79.  
  80.  
  81. import java.util.concurrent.BlockingQueue;
  82.  
  83. public class Sender {
  84. public Sender(BlockingQueue queueOut) {
  85. }
  86.  
  87. public Sender(BlockingQueue<Integer> queueIn, BlockingQueue<Integer> queueOut) {
  88.  
  89. }
  90.  
  91. public void write(){
  92. System.out.println("written text");
  93.  
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement