aspose file tools*
The moose likes Beginning Java and the fly likes problem with classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem with classes" Watch "problem with classes" New topic
Author

problem with classes

tyler jones
Ranch Hand

Joined: Dec 01, 2000
Posts: 101
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 ]
Shivaji Marathe
Ranch Hand

Joined: Jan 11, 2002
Posts: 203
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with classes