[concurrency-interest] deadline and long overflow
alarmnummer at gmail.com
Wed Apr 20 09:57:43 EDT 2016
Thanks for the replies.
The question is not about waiting given amount of time; but the calculation
of the deadline itself which can become negative due to overflow. So
imagine you call:
then the deadline will be < 0 due to overflow.
The question is if it can happen that a blocking call fails with a timeout,
perhaps immediately due to this deadline becoming negative. I made some
small examples and it seems to self correct like David suggested but it
feels a bit funny.
On Wed, Apr 20, 2016 at 3:52 PM, Doug Lea <dl at cs.oswego.edu> wrote:
> On 04/20/2016 06:32 AM, Alex Otenko wrote:
>> Wouldn’t that be a deadline of 500-odd years?
> Overflow issues can occur in half that time though (around 292 years).
>> Technically, overflow is a possibility. Practically - very unlikely.
> Right. There is a disclaimer about this in System.nanotime:
> This could be repeated in every timing-related method, but isn't.
>> On 20 Apr 2016, at 11:05, Peter Veentjer <alarmnummer at gmail.com
>>> <mailto:alarmnummer at gmail.com>> wrote:
>>> I have a question regarding dealing with deadlines and long overflow.
>>> For example the following from the SynchronousQueue:
>>> final long deadline = timed ? System.nanoTime() + nanos :0L;
>>> What would happen if someone calls queue.offer(item, Long.MAX_VALUE,
>>> then deadline overflows and becomes negative. I see the same approach in
>>> parts e.g.
>>> this.deadline = timed ? System.nanoTime() + nanos :0L;
>>> from the Phaser. Personally I like the simplicity; but my concern is
>>> Concurrency-interest mailing list
>>> Concurrency-interest at cs.oswego.edu <mailto:
>>> Concurrency-interest at cs.oswego.edu>
>> Concurrency-interest mailing list
>> Concurrency-interest at cs.oswego.edu
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Concurrency-interest