The following scneario is what i was thinking of:
- 2 Threads, 1 Producer, 1 Consumer
- T1 creates the Queue and starts the next thread, and is repsonsible for puting elements into the queue
ServerThread implements Runnable{
run(){
BlockingQueue q = new ArrayBlockingQueue(1024);
ListenerThread lt = new ListenerThread8(q);
lt.start();
....
q.put(message);
}
}
-T2 will wait for elements in the queue and handles them
ListenerThread implements Runnable{
...
run(){
while(run){
if(!q.isEmpty){
sendMessage(q.getfirst());
}else{
sleep(1000);
}
}
}
}
This is just a pseudo implementation of how i want to implement my part of the program.
-Could this work?
-And could this work with the static modifier on the queue?