Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Queue.Poll() is return null but Queue.size() >0 in java queue

Tags:

java

null

queue

My code:

while( Memo.qRcv.size() > 0) {
    MessageReceived msg=Memo.qRcv.poll();
    ...
}

Then I got

2014-03-01 11:09:36 DEBUG [Thread-16] (threadQueueSendtoUser.java:163) - Memo.qRcv = null, size = 41590
like image 302
Lee Tea Avatar asked Oct 01 '22 11:10

Lee Tea


1 Answers

I found solution by using ConcurrentLinkedQueue http://www.javacodex.com/Concurrency/ConcurrentLinkedQueue-Example

Problem here is I used 2 thread to process a Queue, should not use normal queue. I will feedback if any problem

Thank you all

like image 166
Lee Tea Avatar answered Oct 17 '22 10:10

Lee Tea