I am experiencing unusually long waits before timeout when using BlockingQueue<T>.poll(long timeout, TimeUnitunit).
I would expect poll() to timeout within operating system timer precision error (e.g. 15ms on Windows).
According to my tests poll() waits alot longer.
For example, if timeout is set to 2000ms, poll() timeout occurrs after ~3200ms and not after (as I would expect) ~2015ms.
I do not understand why the precision of BlockingQueue.poll() timeout is so poor.
If I cannot rely on poll() to wait "up to" (as stated in javadoc) specified timeout, I do not see the practical use for this method.
(or should "up to" be understood as "never less than but can be extremly over specified timeout")
Could anyone please shed some light on this matter and maybe point me in the right direction as to what am I doing wrong ?
Is my understanding of what poll() should be used for and when wrong ?
Here is my test code which measures how long did poll() wait before timing out & the resulting output.
(Windows XP SP3, jre 188.8.131.52)