Java Threads mailing list archive

Re: Java Tip 68: Learn how to implement the Command pattern in Java -

From: Rick Beton <rdb@roke.co.uk>
Date: Fri, 12 Feb 1999 14:52:12 +0000

--------------AA8C21391B80CEC5C5D17E9D
Content-Type: text/plain; charset="us-ascii"

"P.H.Welch" wrote:

> <snip>
>
> In JDK1.1, such event handling was deprecated and replaced with
> a traditional (non-`object-oriented') listener-callback mecahnism.

If I understand correctly, it's not quite correct to call the
listener-callback mecahnism 'non object oriented' just because it doesn't use
inheritance. The term often used is the 'delegate model', I believe, as
distinct from the 'inheritance model'.


> <snip>

> My question is: does the un-thread-safeness of Swing configuration
> methods just mean that we can't invoke them safely from multiple
> threads?  <snip>

> OR ... does the declared un-thread-safeness of Swing configuration
> methods mean that they *must* be executed only by the JVM Event thread
> (i.e. using `invokeLater')?  <snip>

The latter is true, except for a very few exceptions. It has to run GUI
interactions in the JVM Event thread. I quote:

     Rule: Once a Swing component has been realized, all code that might
     affect
     or depend on the state of that component should be executed in the
     event-dispatching thread.

URL for further reading:
http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html

Rick
--
Richard Beton B.Sc. C.Phys. M.Inst.P.
Roke Manor Research Limited (http://www.roke.co.uk/)
--------- Standard Disclaimer about my own views etc etc --------
---------  My mail client accepts rich text (HTML) mail  --------
Welsh Highland Railway: http://www.whr.co.uk/WHR/WHR.html


--------------AA8C21391B80CEC5C5D17E9D
Content-Type: text/html; charset="us-ascii"

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
"P.H.Welch" wrote:
<blockquote TYPE=CITE><snip>
<p>In JDK1.1, such event handling was deprecated and replaced with
<br>a traditional (non-`object-oriented') listener-callback mecahnism.</blockquote>
If I understand correctly, it's not quite correct to call the listener-callback
mecahnism 'non object oriented' just because it doesn't use inheritance.
The term often used is the 'delegate model', I believe, as distinct from
the 'inheritance model'.
<br> 
<blockquote TYPE=CITE><snip></blockquote>

<blockquote TYPE=CITE>My question is: does the un-thread-safeness of Swing
configuration
<br>methods just mean that we can't invoke them safely from multiple
<br>threads?  <snip></blockquote>

<blockquote TYPE=CITE>OR ... does the declared un-thread-safeness of Swing
configuration
<br>methods mean that they *must* be executed only by the JVM Event thread
<br>(i.e. using `invokeLater')?  <snip></blockquote>
The latter is true, except for a very few exceptions. It has to run GUI
interactions in the JVM Event thread. I quote:
<blockquote><b>Rule</b>: Once a Swing component has been realized, all
code that might affect
<br>or depend on the state of that component should be executed in the
<br>event-dispatching thread.</blockquote>
URL for further reading:
<br><A HREF="http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html">http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html</A>
<p>Rick
<br>--
<br>Richard Beton B.Sc. C.Phys. M.Inst.P.
<br>Roke Manor Research Limited (<A HREF="http://www.roke.co.uk/">http://www.roke.co.uk/</A>)
<br>--------- Standard Disclaimer about my own views etc etc --------
<br>---------  My mail client accepts rich text (HTML) mail 
--------
<br>Welsh Highland Railway: <A HREF="http://www.whr.co.uk/WHR/WHR.html">http://www.whr.co.uk/WHR/WHR.html</A>
<br> </html>

--------------AA8C21391B80CEC5C5D17E9D--

	


Last updated: Tue Nov 2 12:11:31 1999
Maintained by Peter Welch.