I had a queue implemented as a linked list on my multi-threaded server. I want to access this queue from another class. Both classes are in the same package. I tried to make this queue public statics and access it via getter, but to no avail. Can someone tell me exactly what the problem is.
This is my code: Queue declaration:
public static Queue<Request> q=new ConcurrentLinkedQueue<Request>();
public static void setQ(Queue<Request> q) {
Connection.q = q;
}
public static Queue<Request> getQ() {
return q;
}
Available Queue:
Queue<Request> queue=new ConcurrentLinkedQueue<Request>();
queue=Connection.getQ();
Adding a value to a queue in a connection thread
q.add(r);
source
share