[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bsf-discussion
Subject:    Re: [bsf-discussion] Starting Java threads from (rhino) JavaScript ?
From:       Norris Boyd <nboyd () atg ! com>
Date:       2001-02-16 21:54:11
[Download RAW message or body]

Ah. The problem is that the Thread constructor is overloaded. One form takes a
Runnable, but another takes a String. When you passed the XMLPipe object (yes,
in JavaScript constructors are functions are objects) to Thread, the overload
resolution picked the String form of the constructor to call and then ran
toString on the XMLPipe constructor object.

- --N

Aaron Aston wrote:

> Ok, I've figured this out -- that is, I know what was broken and I know how
> to fix it.  I'm not sure what code was running and why Rhino didn't generate
> an error message ...
>
> I had the following script:
>
>   var pipe = new XMLPipe(Results, attributes, CollectionName, EntryName);
>   err.println("script: starting thread...");
>   var thread = new Packages.java.lang.Thread(XMLPipe);
>
> XMLPipe implements Runnable.  Notice the third line.  I made a mistake and
> passed class name instead of the instance.  Above this line I ran a Rhino
> "importPackage()" on the package of XMLPipe, and I think Rhino creates
> objects to represent packages and classes.  I have no idea how the thread
> instance was created with whatever class rhino used to represent "XMLPipe".
> I could talk to the thread though because I was querying isAlive() etc ...
> Weird.
>
> Thanks for the respones ....
>
> -----Original Message-----
> From: Aaron Aston [mailto:aaston@enghouse.com]
> Sent: Friday, February 16, 2001 2:41 PM
>
> Sorry, I think this is a false alarm ...
>
> I wrote a simple test case that starts a thread on a Java Runnable instance
> (not a wrapped JS object as below) and it works fine ... I must be broken
> somewhere else.
>
> ----
> To get off the bsf-discussion list, send a message containing the word
> "unsubscribe" (in the body, not the subject) to
> <bsf-discussion-Request@OSS.Software.IBM.Com>.
>
> Send Majordomo commands to: <bsf-discussion-Request@OSS.Software.IBM.Com>
> To contact a human:         <bsf-discussion-Owner@OSS.Software.IBM.Com>
> To post to the list:        <bsf-discussion@OSS.Software.IBM.Com>


- ----
To get off the bsf-discussion list, send a message containing the word
"unsubscribe" (in the body, not the subject) to
<bsf-discussion-Request@OSS.Software.IBM.Com>.

Send Majordomo commands to: <bsf-discussion-Request@OSS.Software.IBM.Com>
To contact a human:         <bsf-discussion-Owner@OSS.Software.IBM.Com>
To post to the list:        <bsf-discussion@OSS.Software.IBM.Com>
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic