• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

is multithreading needed?

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all

i have a swing application with timer and a jtextarea and a few buttons and fields built in. The jtextarea acts as a console and i will be printing everything out in there.

i realised that when the timer is running and executing instruction, my applciation will freeze and button cannot be press. what is frustrating is that the jtextarea is not updated and only do so after the timer stop.

I thought that timer is running on another thread?

any advise on this ?
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well. i guess multithreading should be the solution..... anybody got nice multithreading resource to share? those in sun microsystem is pretty old article ( back in 2001)
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Swing API
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out javax.swing.SwingWorker. That's the easiest way to handle threading in Swing.
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for the tips.. i am reading the tutorial now......

by the way, if i want to create more than two threads do i create more of the SwingWorker object?

how do i keep track of all these thread and cancel them when i want?
 
Rob Spoor
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need one SwingWorker for each thread you want to run concurrently.

This is going away from Swing and more towards threads in general, so I'm moving this to the threads forum.
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so if i have different swingworkers ........ how i keep track of them?

which method can allow me to differentiate them? so as to cancel it..... ?

thank you
reply
    Bookmark Topic Watch Topic
  • New Topic