Hi Joe,
> Another question: I started down an alternate path to use
> java.net.ServerSocket but it doesn't seem to like threads/thread pool
> calls.
>
> Here's a really simple example:
>
> : (setq Thread (java "java.lang.Thread" T (interface
> "java.lang.Runnable" 'run '(() (prinl "hi"))))))
> -> $Thread
> (java Thread "start")
> : -> NIL
> : Exception in thread "Thread-1" java.lang.NullPointerException
HA! You found a bug in 'interface' :)
It seems that 'interface' could not handle correctly functions with
empty parameter lists, like the above '(() ..). This resulted in the
NullPointer exception.
I fixed "ersatz/fun.src":
239a240,242
> if (arg == null)
> return w.apply(null, false, null, 0);
> else {
244a248
> }
(also uploaded a fixed version).
With that:
abu:~/pico ersatz/pil +
: (setq Thread
(java "java.lang.Thread" T
(interface "java.lang.Runnable" 'run '(() (prinl "hi"))) ) )
(java Thread "start")
-> $Thread
: -> NIL
: hi
BUT! While this simple example works, I'll have to warn stronly to use
Java threads in real code. The problem is the same as with the other
versions of PicoLisp: Threads cannot be handled cleanly, due to symbol
binding conflicts. You'll open a pandora box, because each thread will
overwrite the other thread's bindings.
Unfortunately, Java doesn't come with a fork() system call ...
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe