Question for those familiar with Java ....

  • Thread starter Thread starter temp2
  • Start date Start date
T

temp2

Hello,

I've done some Java in the past. I don't remember ever having to worry
about updating a control from a thread other than the one that created
it. In C# you have to jump throught a bunch of hoops to with Invoke/
BeginInvoke or use tricks with BackgroundWorker. I don't remember
having to do this with Java. Java runs is in a "managed" environment
like C#. Is it because Swing is thread safe?

TIA
 
I've done some Java in the past. I don't remember ever having to worry
about updating a control from a thread other than the one that created
it. In C# you have to jump throught a bunch of hoops to with Invoke/
BeginInvoke or use tricks with BackgroundWorker. I don't remember
having to do this with Java. Java runs is in a "managed" environment
like C#. Is it because Swing is thread safe?

No, Swing has the same rules as Windows Forms. That's what the
SwingWorker class exists for. See
http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html
 
Hello,

I've done some Java in the past. I don't remember ever having to worry
about updating a control from a thread other than the one that created
it. In C# you have to jump throught a bunch of hoops to with Invoke/
BeginInvoke or use tricks with BackgroundWorker. I don't remember
having to do this with Java. Java runs is in a "managed" environment
like C#. Is it because Swing is thread safe?

A quick google shows that Swing is primarily not thread safe. You were
probably just lucky in the past that nothing went wrong.

http://groups.google.com/group/comp...ing+thread+safe&rnum=1&hl=en#443b1cd60d7e422b

PS
 
A quick google shows that Swing is primarily not thread safe. You were
probably just lucky in the past that nothing went wrong.

http://groups.google.com/group/comp.lang.java.gui/browse_thread/threa...

PS

A reason why UI Components are not thread safe are because, any update
to UI components should not be blocked by a running thread as a block
on UI update would bring about a slow, non-responsive UI. This
violates the design goal of a Graphical User Interface.
 
PS said:
A quick google shows that Swing is primarily not thread safe. You were
probably just lucky in the past that nothing went wrong.

Similar to .NET 1.1, which does not check like 2.0 does.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top