Operating System - OpenVMS
1753781 Members
7529 Online
108799 Solutions
New Discussion

LiveConnect Applet Architecture Bug with Thread utilization (with SSCCE!)

 
Richard J Maher
Trusted Contributor

LiveConnect Applet Architecture Bug with Thread utilization (with SSCCE!)

Hi,

Not sure if Bojan still responds here or if anyone else might be able to help but I make no claim to being either a Javascript or JAVA expert so, before logging a bug report with SUN/Oracle, I would appreciate those here with relevant skills casting a critical eye of my small reproducer to see if the anomalies can be explained as simple pilot error rather than a bug in the plugin code.

To reproduce the example locally, save the three text files attached to the filenames and extensions specified. Then: -
javac -cp "c:\Program Files\Java\jdk1.6.0_22\jre\lib\plugin.jar" OutThread.java
javac -cp ".;c:\Program Files\Java\jdk1.6.0_22\jre\lib\plugin.jar" Sleeper.java
jar -cf Sleeper2.jar Sleeper.class OutThread.class

NB* The above specified the classpath so as to match my version and Windows location of the relevant bits from the SDK. Your OS, Java Version and SDK path may vary or may already be defined.

Once you have compiled the two classes into the JAR, copy Sleeper2.jar and dyntest_embed.html to your web root directory. Pull up http://127.0.0.1/dyntest_embed.html with your FireBug/DeveloperTools Console window enabled and your JAVA console enabled and watch what happens. It can take up to 30,000 iterations or as little as 100 but you will see the "hang". (If you become impatient you can add further tabs with the same page (work the static vars) or load the browser instance and/or machine)

What I observe and accuse the plugin of doing is allocating the wrong work to the wrong thread. That is, unlike the documented behaviour that can be seen at: -
http://download.oracle.com/javase/6/docs/technotes/guides/jweb/applet/applet_execution.html#threads
I believe that something makes the plugin lose track of the Thread pool and allocate the setBack()/notifyAll() call to the LiveConnect worker thread (when it should go to "Fred") and horror of horrors, my consumer thread
"Fred" that should be exclusively processing jobs on the queue sometimes is allocated producer work (getNum()) which leads to an unavoidable deadlock :-(

Actual example output: -
[1]in getNum() 2490 caller [TO3] Thread Applet 1 LiveConnect Worker ThreadThread[Applet 1 LiveConnect Worker Thread,4,http://127.0.0.1/-threadGroup] hash 19c0bd6
[1]Queueing work
[1]Going for wait
**[2]in getNum() 2409 caller [TO2] Thread
FredThread[Fred,4,http://127.0.0.1/threadGroup] hash 1827d1**
[2]Queueing work
[2]Going for wait

This can be observed with FF and/or IE8 (Chrome doesn't seem to fail with only one tab but with multiple dyntest_embed.html tabs the results can be reproduced).

Does it coincide with garbage collection? Is the code/logic fundamentally flawed? Is it a LiveConnect Thread management bug in desperate need of correction?

Cheers Richard Maher
1 REPLY 1
Richard J Maher
Trusted Contributor

Re: LiveConnect Applet Architecture Bug with Thread utilization (with SSCCE!)

Ok, I've created a bug report for this on SDN: -
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7001755.

At priority 4 I'm not going to hold my breath but if you can spare 5 minutes could you please vote for a resolution to this bug via: -
http://bugs.sun.com/bugdatabase/addVote.do?bug_id=7001755.

I don't understand why more people are not anxious of the debilitating effects of this bug.

Cheers Richard Maher