🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
3 messages
3 total messages Started by Aleksandar Pecanov Thu, 09 Oct 2003 00:19
SwingUtilities invokeLater
#1557
Author: Aleksandar Pecanov
Date: Thu, 09 Oct 2003 00:19
7 lines
1447 bytes
I remember that while working on Windows, when I wanted to run a separate
thread to aupdate a swing component (for example a memory indicator), I
had run the thread with SwingUtilities.invokeLater(). However, while
working under Linux, I forgot to use it. The component worked fine. Is
the implementation of threads and thread synchronization in Java different
on Windows and Linux. If so, where can I find more information about what
should I pay attention when developing multiplatform Java Application?
Re: SwingUtilities invokeLater
#1569
Author: Tad Frysinger
Date: Mon, 13 Oct 2003 15:06
27 lines
2405 bytes
It is very different (depending on which JDK version, which Linux 
version), but you should definitely NOT change your code to leave it up 
to the OS in this situation. You just may have not hit the contention in 
Linux yet, and in any event can't depend on that behavior being 
consistent from release to release. Using SwingUtilities insures that 
you won't have a problem by making the single AWT thread responsible for 
updating all the UI, regardless from which thread the original UI 
request came from.

In terms of resources, there is an interesting section in the "Taming 
Java Threads" book by Holub (or go to 
http://www.holub.com/publications/articles/index.html for lots of 
interesting stuff by this guy) on differences in threading between 
Windows and *nix (primarily Solaris, but the issues apply).

Tad Frysinger
[TeamB]

Aleksandar Pecanov wrote:
> I remember that while working on Windows, when I wanted to run a separate
> thread to aupdate a swing component (for example a memory indicator), I
> had run the thread with SwingUtilities.invokeLater(). However, while
> working under Linux, I forgot to use it. The component worked fine. Is
> the implementation of threads and thread synchronization in Java different
> on Windows and Linux. If so, where can I find more information about what
> should I pay attention when developing multiplatform Java Application?
> 
Re: SwingUtilities invokeLater
#1418
Author: James Acker
Date: Sun, 09 Nov 2003 11:18
74 lines
4277 bytes
Sorry for crashing this thread....but I just wondered, since the thread is
about invokeLater if someone could advise me on if this could be part of my
problem too...

I have an application that uses
gridBagLayout as the layout manager.

Somewhere in the code the app sets up for an image (A4...like letter size)
to be displayed AND in a separate thread (implementing Runnable) calls a
method that will set the scroll bar to the bottom of the image. It sets up
the run method, and then calls SwingUtils.invokeLater.

The problem is this is unstable. Often, but not always, the image stays
(with scrollbar) at the top. I may have misunderstood but I tried a few
things, one being calling it as "synchronized" which at first I thought
helped but the problem returned. Also I tried changing the invokeLater to
"invokeAndWait" and still it happens.

This is inherited code, I didn't write it, and I surely have to spend more
time checking all the logic in it...but generally it seems like nothing I do
can insure that the scrollToBottom (one of the methods) works and is done
corectly before continuing.

I am not writing out the code here, so I am not necessarily asking for
someone to solve this for me, but if anyone had some similar experience and
could share general tips about this I would be interested to hear.

Thanks,

Jim


--
====================================================
             Check out my original music at
http://www.soundclick.com/bands/1/jackermusic.htm

"In theory there is no difference between theory and practice,
but not in practice."
====================================================

"Tad Frysinger" <tfrysinger@earthlink.net> skrev i melding
news:3F8ABF88.4000807@earthlink.net...
> It is very different (depending on which JDK version, which Linux
> version), but you should definitely NOT change your code to leave it up
> to the OS in this situation. You just may have not hit the contention in
> Linux yet, and in any event can't depend on that behavior being
> consistent from release to release. Using SwingUtilities insures that
> you won't have a problem by making the single AWT thread responsible for
> updating all the UI, regardless from which thread the original UI
> request came from.
>
> In terms of resources, there is an interesting section in the "Taming
> Java Threads" book by Holub (or go to
> http://www.holub.com/publications/articles/index.html for lots of
> interesting stuff by this guy) on differences in threading between
> Windows and *nix (primarily Solaris, but the issues apply).
>
> Tad Frysinger
> [TeamB]
>
> Aleksandar Pecanov wrote:
> > I remember that while working on Windows, when I wanted to run a
separate
> > thread to aupdate a swing component (for example a memory indicator), I
> > had run the thread with SwingUtilities.invokeLater(). However, while
> > working under Linux, I forgot to use it. The component worked fine. Is
> > the implementation of threads and thread synchronization in Java
different
> > on Windows and Linux. If so, where can I find more information about
what
> > should I pay attention when developing multiplatform Java Application?
> >
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads