Results 1 to 3 of 3
  1. #1
    elin is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Default SwingWorker or just plain thread

    Hello,

    I'm trying to write an application which reads streaming information from a socket and displays it in graphical form. I'm using a Java Swing application. Should I put the code for reading information from the socket in a Swingworker thread or just a plain thread. By plain thread I mean something like:

    private static class MessageLoop implements Runnable {
    ..

    Thanks!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,903
    Rep Power
    25

    Default

    I think a SwingWorker would use the same type of Thread as you'd create.
    The reason to use it would be ease of use or to use with other classes.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Agrees with Norm and also will add that if you decide to go with the non-SwingWorker background thread, take care to call all Swing-related code on the EDT (Event Dispatch Thread) by placing it in a Runnable and call in the parameter of a SwingUtilities.invokeLater(....) call. Much luck!

Similar Threads

  1. plain text printing with java
    By berkeleybross in forum Advanced Java
    Replies: 3
    Last Post: 04-04-2011, 02:01 AM
  2. Replies: 3
    Last Post: 06-08-2010, 09:10 PM
  3. Swingworker or new thread
    By cotarelo in forum Threads and Synchronization
    Replies: 3
    Last Post: 03-24-2010, 07:59 PM
  4. Font.PLAIN - won't set font style to PLAIN!
    By Unsub in forum New To Java
    Replies: 3
    Last Post: 03-11-2010, 01:13 PM
  5. Indentation - plain text
    By barney75 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 06:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •