Java performance problem with LinkedBlockingQueue
Posted
by lofthouses
on Stack Overflow
See other posts from Stack Overflow
or by lofthouses
Published on 2010-04-15T11:08:38Z
Indexed on
2010/04/15
11:23 UTC
Read the original article
Hit count: 512
Hello,
this is my first post on stackoverflow...i hope someone can help me
i have a big performance regression with Java 6 LinkedBlockingQueue. In the first thread i generate some objects which i push in to the queue In the second thread i pull these objects out. The performance regression occurs when the take() method of the LinkedBlockingQueue is called frequently. I monitored the whole program and the take() method claimed the most time overall. And the throughput goes from ~58Mb/s to 0.9Mb/s...
the queue pop and take methods ar called with a static method from this class public class C_myMessageQueue {
private static final LinkedBlockingQueue<C_myMessageObject> x_queue = new LinkedBlockingQueue<C_myMessageObject>( 50000 );
/**
* @param message
* @throws InterruptedException
* @throws NullPointerException
*/
public static void addMyMessage( C_myMessageObject message )
throws InterruptedException, NullPointerException {
x_queue.put( message );
}
/**
* @return Die erste message der MesseageQueue
* @throws InterruptedException
*/
public static C_myMessageObject getMyMessage() throws InterruptedException {
return x_queue.take();
}
}
how can i tune the take() method to accomplish at least 25Mb/s, or is there a other class i can use which will block when the "queue" is full or empty.
kind regards
Bart
P.S.: sorry for my bad english, i'm from germany ;)
© Stack Overflow or respective owner