• Post Reply Bookmark Topic Watch Topic
  • New Topic

Beginning threads  RSS feed

 
Martin Thorpe
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not too sure if this should be in beginners or threads.. but I am looking at threads for the first time. Whilst I understand the theory behind a thread I am having problems implementing.

This is my test scenario.

One object that implements runnable with a run() that draws a splash screen.

Now in my main I want to run the splash screen, pause it, then build my gui and then hide the splash screen.
I do not want to use the sleep() method to pause my splash screen object as I want it to only hide once everything is done. This is my main:



This is the beginning run of my splash screen class




This is the pause bit in the splash screen class



Now the problem is the splash screen never gets to do its bit.. it never draws its screen, which I would imagine would be done by the run() when I call start in my main. It never shows the System.out.println("showing splash"); or the "waiting"!?!?

What am I doing wrong? Have I missed the boat entirely on Threads? Haveing real problems trying to get my head around this.. any bit of help would be much appreciated.

Thanks for reading

cheers
Martin
[ October 20, 2004: Message edited by: Martin Thorpe ]
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to your scenario I would do the following:
- in main method create the splash dialog
- form the splash dialog start a new thread to build the main window using SwingUtilities and taken care not to show it (you run in threading issues otherwise)
- return from the dialog the new initialized main window and just show() it.

./pope
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!