<div dir="ltr">Hi James,<div><br></div><div>My thinking is that the wait time is being rounded to zero, which might be used internally by Java to encode an indefinite wait.</div><div><br></div><div>Does the patch below work for you?</div>
<div><br></div><div>Bye,</div><div><br></div><div>Erik.</div><div><br></div><div><br></div><div><div>Index: LispThread.java</div><div>===================================================================</div><div>--- LispThread.java<span class="" style="white-space:pre"> </span>(revision 14464)</div>
<div>+++ LispThread.java<span class="" style="white-space:pre"> </span>(working copy)</div><div>@@ -1004,11 +1004,12 @@</div><div> };</div><div> </div><div> </div><div>+ private static DoubleFloat factor1000 = new DoubleFloat(1000);</div>
<div>+</div><div> public static final long javaSleepInterval(LispObject lispSleep)</div><div>-</div><div> {</div><div> double d =</div><div>- checkDoubleFloat(lispSleep.multiplyBy(new DoubleFloat(1000))).getValue();</div>
<div>+ checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();</div><div> if (d < 0)</div><div> type_error(lispSleep, list(Symbol.REAL, Fixnum.ZERO));</div><div> </div><div>@@ -1015,6 +1016,17 @@</div>
<div> return (d < Long.MAX_VALUE ? (long) d : Long.MAX_VALUE);</div><div> }</div><div> </div><div>+ public static final int javaSleepNanos(LispObject lispSleep)</div><div>+ {</div><div>+ double d = // d contains millis</div>
<div>+ checkDoubleFloat(lispSleep.multiplyBy(factor1000)).getValue();</div><div>+ double n = d*1000000; // n contains nanos</div><div>+ d = 1.0e6*((long)d); // convert rounded millis to nanos</div>
<div>+ n = n - d; // retain nanos not in millis</div><div>+</div><div>+ return (n < Integer.MAX_VALUE ? (int) n : Integer.MAX_VALUE);</div><div>+ }</div><div>+</div><div> @DocString(name="sleep", args="seconds",</div>
<div> doc="Causes the invoking thread to sleep for SECONDS seconds.\n"+</div><div> "SECONDS may be a value between 0 1and 1.")</div><div>@@ -1025,7 +1037,8 @@</div><div> {</div><div>
</div><div> try {</div><div>- Thread.sleep(javaSleepInterval(arg));</div><div>+<span class="" style="white-space:pre"> </span> Thread.sleep(javaSleepInterval(arg),</div><div>+<span class="" style="white-space:pre"> </span> javaSleepNanos(arg));</div>
<div> }</div><div> catch (InterruptedException e) {</div><div> currentThread().processThreadInterrupts();</div><div>@@ -1208,7 +1221,8 @@</div><div> </div><div> {</div><div>
try {</div><div>- object.lockableInstance().wait(javaSleepInterval(timeout));</div><div>+<span class="" style="white-space:pre"> </span> object.lockableInstance().wait(javaSleepInterval(timeout),</div>
<div>+<span class="" style="white-space:pre"> </span> javaSleepNanos(timeout));</div><div> }</div><div> catch (InterruptedException e) {</div><div> currentThread().processThreadInterrupts();</div>
</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 1, 2014 at 2:54 PM, James M. Lawrence <span dir="ltr"><<a href="mailto:llmjjmll@gmail.com" target="_blank">llmjjmll@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">(defun test ()<br>
(let ((object (cons nil nil)))<br>
(threads:synchronized-on object<br>
(threads:object-wait object 0.0001))))<br>
<br>
For times between 0 and 0.0001 this appears to hang indefinitely. No<br>
problem with times above 0.001.<br>
<br>
The context is the new timeout option for bordeaux-threads:condition-wait,<br>
<br>
<a href="https://github.com/sionescu/bordeaux-threads/blob/master/src/impl-abcl.lisp#L101" target="_blank">https://github.com/sionescu/bordeaux-threads/blob/master/src/impl-abcl.lisp#L101</a><br>
<br>
1.3.0-dev-svn-14623<br>
Java_HotSpot(TM)_Server_VM-Oracle_Corporation-1.7.0_04-b20<br>
i386-Linux-3.2.0-24-generic-pae<br>
<br>
Best,<br>
lmj<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Bye,<div><br></div><div>Erik.</div><div><br></div><div><a href="http://efficito.com/" target="_blank">http://efficito.com</a> -- Hosted accounting and ERP.</div>
<div>Robust and Flexible. No vendor lock-in.</div></div>
</div>