• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threading from seperate class  RSS feed

 
Mark Bugg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to have a re-usable GUI progress indicator that could be called from any other class. I am having trouble getting this to work. My code is below.

**The class that uses the progress indicator**

** The progress indicator class **


This whole setup works great if the run() method is in the FlashWriteUI class.. but doesnt do much when setup like it is here. Any help on this for a java threading newbie would be greatly appreciated!

Thanks
Mark Bugg

PS. Many thanks to the Ranch for helping me get this far already!

[ October 28, 2005: Message edited by: Mark Bugg ]
[ October 28, 2005: Message edited by: Mark Bugg ]
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What seems to be the problem?
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ProgressIndicator is never made visible. You start it up in a new Thread, that executes it's run() method but you never actually make it visible. The FlashWriteUI is visible, but it's the ProgressIndicator that needs to be. In fact, I see no reason for FlashWriteUI to be a JFrame at all, it's not displaying anything. The ProgressIndicator is a JFrame itself, therefore it does not need a FlashWriteUI to display it.

Are you expecting the main method in ProgressIndicator to be executed even when you launch via FlashWriteUI?
 
Mark Bugg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ive taken all the implementation details out of my code to make this problem a little easier to explain. In the code below I will synchronize on object "b" inside of object "b". My understanding says that the monitor is the released again when the wait() is called. Then object "a" should be able to sychronize on object "b"'s monitor. However when notifyAll() is called I get an IllegalMonitorStateException. So object "a" starts a thread using obect "b" but then is not the owner. I am not sure how to get around this. Any help would be greatly appreciated.

 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


That would attempt to notifyAll() on the current instance of object a, not object b.
 
Mark Bugg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. I finally figured this out and then read your post. So the jist of this is that when i was calling notifyAll() it was REALLY saying this.notifyAll() while i was trying to sychronize on b. Changed this and it works like a dream. Thanks for everyones help!!
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!