Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3112

Re: Opposite of SwingUtil

From "Lew" <lew@THRWHITE.remove-dii-this>
Subject Re: Opposite of SwingUtil
Message-ID <6sOdnUX7hY0XmjTanZ2dnUVZ_oHinZ2d@comcast.com> (permalink)
Newsgroups comp.lang.java.gui
References <47a8db72$0$3057$7836cce5@newsrazor.net>
Date 2011-04-27 15:42 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Daniel Pitts wrote:
> larkmore@aol.com wrote:
>>> Since you are using the Swing Timer, you are guaranteed that the
>>> actionPerformed method will be invoked on the EDT. Similarly, your
>>> ActionListener for your button will only ever be invoked on the EDT.
>>> Since they will only ever be executed by a single thread, you are
>>> guaranteed that your Timer will never execute in between x and y.
>>>
>>> Rogan
>>
>> Hmm.  Good to know that the Swing Timer's actionPerformed() is always
>> on the EDT, but maybe I used a poor example.  I use the RXTX libraries
>> a lot to communicate with serial ports, and I'm worried about
>> asynchronous data coming from and going into those ports.  I have no
>> idea what thread runs when new data comes in from a serial port, but I
>> have a very strong hunch it won't be the EDT.  Yes/no?  What should I
>> do in that case, or any other case where I know for sure or at least
>> strongly suspect that the thread manipulating the data will not be the
>> EDT one?
>> -Will
> Generally, you can repeat the pattern that Swing took (BTW, you should 
> use EventQueue.invokeLater, not SwingUtilities)
> 
> You can create a "message queue" for your serial port, and have a single 
> thread that reads from that queue and writes the data to your port.  You 
> would have another thread who's job it is to read from and respond to 
> the serial data coming in.  Quite possibly that thread would pass the 
> actual data off to something in the event queue.

You can also use
<http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html>
to invoke jobs off the EDT.

-- 
Lew

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Opposite of SwingUtilitie "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
  Re: Opposite of SwingUtil "Rogan Dawes" <rogan.dawes@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
    Re: Opposite of SwingUtil "larkmore" <larkmore@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
      Re: Opposite of SwingUtil "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
        Re: Opposite of SwingUtil "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:42 +0000
        Re: Opposite of SwingUtil "Stanimir Stamenkov" <stanimir.stamenkov@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
          Re: Opposite of SwingUtil "Daniel Pitts" <daniel.pitts@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000
      Re: Opposite of SwingUtil "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:43 +0000

csiph-web