• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

problem with classes

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write a class that creates an object of another class. When I run my code, I expect to see a messagebox when the timer reaches the time passed in to the object, but it doesn't. I thought maybe it was because the program hit the end of the main method, so I threw in the thread to keep it executing, but it still didn't give me the message box. Can anyone tell me what I'm doing wrong? Thanks.

[ June 03, 2002: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are creating a new thread, but you are not really doing anything with it. When you run your program, the main() method runs on one thread. If you want to start another thread and execute some code on that thread, you have to either
extend a thread,
override it's run method and put the code you want to execute on the separate thread in the run method
and then call the Thread.start to execute the code.
OR you can create an object that implements the runnable interface,
provide a run method to this object and
then create a thread with this object as an argument and then call the Thread.start to execute the code on a separate thread.
HTH
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic