Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #4866
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | markspace <-@.> |
| Newsgroups | comp.lang.java.gui |
| Subject | Re: Canvas Wanted (simple question) |
| Date | Sat, 24 Dec 2011 06:47:16 -0800 |
| Organization | A noiseless patient Spider |
| Lines | 59 |
| Message-ID | <jd4olm$43e$1@dont-email.me> (permalink) |
| References | <4ee52877$0$5797$65785112@news.neostrada.pl> <jc3fu9$31u$1@dont-email.me> <8lxthes2ckbz.x1cfm0fm94x5$.dlg@40tude.net> <jd39ov$s2l$1@dont-email.me> <ak7y2yg4r0yg$.1pv48s4znh5ba$.dlg@40tude.net> <jd3oot$oam$1@dont-email.me> <gz0g3hjra46f.zyihcfi3lv28.dlg@40tude.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Sat, 24 Dec 2011 14:47:19 +0000 (UTC) |
| Injection-Info | mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="4206"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18lVYOmbPnTvvyai5npRg0wpLYww3zCcOw=" |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
| In-Reply-To | <gz0g3hjra46f.zyihcfi3lv28.dlg@40tude.net> |
| Cancel-Lock | sha1:cn685yAsiwNXOdH39/Zg/GX8E9s= |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.gui:4866 |
Show key headers only | View raw
On 12/24/2011 5:16 AM, Joerg Meier wrote:
> On Fri, 23 Dec 2011 21:42:51 -0800, markspace wrote:
>
>> On 12/23/2011 6:41 PM, Joerg Meier wrote:
>>> Only you clearly didn't read my post other farther than "doesn't need to be
>>> wrapped".
>> Yes I clearly did, and I clearly explained why your assumption was
>> incorrect.
>
> Then what you said makes no sense. Events will fire on a thread before the
> thread exists ? How's that work ?
In the case where callbacks are made on the EDT, they'll be asynchronous
with the main thread and won't wait for the "setVisibile()" call.
You'll be still constructing objects on the main thread and the EDT will
be running and trying to manipulate those objects at the same time.
You have no real control over the EDT, it fires when it wants to. It
isn't going to actually wait for you to call setVisibile(), and it
really never did. That was a mistake in the Java documentation to claim
that the EDT did wait for setVisible().
Here's a question for you now: read the section of the JLS on the Java
memory model. When the main thread starts and creates objects like a
JFrame, those objects write to main memory as they are constructed. How
are those write synchronized with the EDT, esp. with regard to the
visibility of those writes?
Main EDT
call new JFrame
write to main memeory
call new JPanel
write to main memory
call setVisible
--------------------------->
read JFrame object
read JPanel object
These reads don't have any explicit synchronization if you construct
them like shown. There's no guaranteed visibility, and seeing partially
constructed objects is a big possibility. As a practical matter, I know
how the EDT starts and the chance of a data race is small, but because
that's not guaranteed by the documentation, it really really bad
practice. Relying on undocumented internal implementations is grossly
unprofessional.
And all the Swing documentation says not to do this; you're explicitly
told to create all Swing objects on the EDT, not main or any other
thread. So it's bad practice times two.
This information is at least five years old, because it was definitely
there for Java 6. Please refer to some current documentation, you're
basically quoting Java 4 and that's nine years old, nearly a decade now.
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar
Canvas Wanted (simple question) Paweł Lampe <scony@sconysoft.com> - 2011-12-11 22:02 +0000
Re: Canvas Wanted (simple question) Knute Johnson <nospam@knutejohnson.com> - 2011-12-11 15:55 -0800
Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 01:49 +0100
Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 17:26 -0800
Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 03:41 +0100
Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 21:42 -0800
Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 14:16 +0100
Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-24 06:47 -0800
Re: Canvas Wanted (simple question) Knute Johnson <nospam@knutejohnson.com> - 2011-12-23 21:21 -0800
Re: Canvas Wanted (simple question) markspace <-@.> - 2011-12-23 21:48 -0800
Re: Canvas Wanted (simple question) Joerg Meier <joergmmeier@arcor.de> - 2011-12-24 14:20 +0100
Re: Canvas Wanted (simple question) "John B. Matthews" <nospam@nospam.invalid> - 2011-12-24 11:22 -0500
Re: Canvas Wanted (simple question) Roedy Green <see_website@mindprod.com.invalid> - 2011-12-12 09:58 -0800
Re: Canvas Wanted (simple question) Paweł Lampe <scony@sconysoft.com> - 2011-12-14 15:57 +0000
Re: Canvas Wanted (simple question) Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-12-14 10:21 -0800
csiph-web