Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

dispatch thread not able to run  RSS feed

 
Alexander Rudloff
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately I don't have a sample program to include to illustrate, but..

Basically, we have a gui that is running an exec as part of a process. The process passes information back and should be displayed as an updating label on the UI. The swing thread isn't running until the exec is finished, then handles all the updates all at once. We've tried offloading it into a seperate thread/invoke later, also a swing worker (kinda the same thing?), we've tried sleep and yeild..

Maybe we're just failing to find the area thats making a call that blocks competing threads, or maybe we're just numb and overlooking something..

I know this may be a vague description, but any feedback? If anything, might help us get over whatever mental-hump
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could try lowering the prioirity of the calculation thread, so the scheduler gives the swing-event-dispath-thread time on the CPU to update your label.
Don.
[ March 02, 2005: Message edited by: Don Kiddick ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alexander,

Calling "invokeLater()" or using a SwingTimer both arrange for the code to be executed on the event thread -- so it's not buying you anything. You need to create your own thread and use that -- i.e.,



Have you tried it this way?
 
Alexander Rudloff
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll try playing with priority, I'm under the impression that that only works as somewhat of a suggestion though? Can't hurt I suppose.

And yeah, they heavy duty operation is in its own thread, which spawns a process and uses .waitFor(). Originally, we thought that might be the problem. The java docs say something to the effect of it blocking the calling thread.. I'm not quite sure if that is whats going on.. It's like both threads are running -- the information being sent to the gui is being logged.. It's just not updating the gui, which would be the swing thread's job. Once it finishes the process and the thread dies, all the label.setText updates run all at once, as if the swing thread is being awakened.

hmm..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!