java - How to pass queues between ExecutorsServices that are in different classes? -


i have created 2 patterns: 1 starts class x (which contains thread started executorservice, name es), second 1 starts class y (which contains thread started es). now, both of them started inside class z es. however, z starts group of threads (es again) directly itself.

public class z {  ... public static void main(string [] args)     {      service=executors.newfixedthreadpool(xnum);         for(int k=0; k < xnum; k++){             x x=new x(k);             service.submit(x);         }      service=executors.newfixedthreadpool(ynum);         for(int k=0; k < ynum; k++){             y y=new y(k);             service.submit(y);         }      service=executors.newfixedthreadpool(znum);         for(int k=0; k < znum; k++){             directthread dt=new directthread(queue1, queue2, queue3);             service.submit(dt);          }     } } 

inside class x there many threads, 1 interests me particularly":

public class x{     ...      public void run(){         while(true){           ...         service = executors.newfixedthreadpool(xstuffnum);         (int i=0; < sstuffnum; i++) {             service.submit(new firstclass(blocking1, blocking2, blocking3));         }         }      } } 

cognately in y class there secondclass. queue , blocking names blockingqueues.

so dt supposed take data firstclass blocking, put them inside queues, , pass them secondclass queues. question is, how let dt take queues inside firsclass?

edit. problem solved. enough create getters inside x , z y can x.getqueue().operation()


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -