A
amullick
I have a swing applet in jdk 1.4 that has a number of focus listeners.
After tracing I've discovered that most of the events are being
assigned to the event queue thread of the applet thread group. However,
some events are also being assigned to the plugin thread group which
contains the console writer thread and its own event queue thread. The
event thread in the plugin thread group runs at a higher priority which
interrupts the event thread in the applet thread group. If the
interrupting and the interrupted methods belong to the same class
depending upon timing, some class objects can get overlaid leading to
unpredictable results. One such result is two blinking carets in two
separate fields at the same time. In addition, the higher priority
thread handles events out of turn. Once the events assigned to the
higher priority thread are exhausted, the event handling by the applet
event thread resumes, and such older events are being handled later.
Out of sequence event handling also carries unpredictable results. For
example a focus gain method might be looking at a component that no
longer has focus.
As a test, when I checked the option to not start the console, the
above symptoms disappeared. The console writer thread was introduced by
Sun as a performance improvement so as not to block println output to
the console. I would like the console to be present because it is being
used for viewing tracing output generated by the applet. This reminds
me of the Uncertainty Principle which says if you look at it, it
changes its behavior. The fact that the jvm schedules event handling in
two separate event threads, looks like a bug. In the meantime, I have
to fix this somehow. Does someone know how to disable the plugin thread
group (containing the console writer thread) without disabling the
console?
Anup
After tracing I've discovered that most of the events are being
assigned to the event queue thread of the applet thread group. However,
some events are also being assigned to the plugin thread group which
contains the console writer thread and its own event queue thread. The
event thread in the plugin thread group runs at a higher priority which
interrupts the event thread in the applet thread group. If the
interrupting and the interrupted methods belong to the same class
depending upon timing, some class objects can get overlaid leading to
unpredictable results. One such result is two blinking carets in two
separate fields at the same time. In addition, the higher priority
thread handles events out of turn. Once the events assigned to the
higher priority thread are exhausted, the event handling by the applet
event thread resumes, and such older events are being handled later.
Out of sequence event handling also carries unpredictable results. For
example a focus gain method might be looking at a component that no
longer has focus.
As a test, when I checked the option to not start the console, the
above symptoms disappeared. The console writer thread was introduced by
Sun as a performance improvement so as not to block println output to
the console. I would like the console to be present because it is being
used for viewing tracing output generated by the applet. This reminds
me of the Uncertainty Principle which says if you look at it, it
changes its behavior. The fact that the jvm schedules event handling in
two separate event threads, looks like a bug. In the meantime, I have
to fix this somehow. Does someone know how to disable the plugin thread
group (containing the console writer thread) without disabling the
console?
Anup