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

timer class

Dale Smirth
Greenhorn

Joined: May 17, 2005
Posts: 14
I am new to Java programming, but intrigued by the paradigm of the object-oriented concept.

I would like to get some input related to my concept before diving into the actual programming.

Is this possible:

I would like to use the Timer class to trigger random threads. The threads do nothing more than sleep for a random amount of time. The thread then terminates.

I had thought about using a while loop, but I ran across the Timer class and it sounds like it could save me a lot of extra coding.

I would be build around this class defintion:

public class CLASSNAME extends JFrame implements Runnable, ActionListener
{
}

This line would use the Runnable interface for threads and use the ActionListener interface for event handling for my gui.

Am I off to a good start?

Thanks

BTW, any input on the implementing the Timer class would be appreciated.
Dhruv Shah
Greenhorn

Joined: May 02, 2005
Posts: 19
The use of Timer class is as this

1. Create the TimerTask. i.e. you extend this class to implement your own task which needs to be done (at/after specific time)




2. Create instance of Timer and then use above task





Hope this helps!


Thanks

www.indianuncle.com
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11231
    
  16

DMa xJ,

I'm betting that you will shortly be asked by a sherrif/bartender to change your name. The policy here is that you must use a real (sounding) first and last name (although i think a first initial is allowed).

The policy is stated here, and you can change your name here.

thanks!!!


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Dale Smirth
Greenhorn

Joined: May 17, 2005
Posts: 14
Okay, I think that I am on the right track.

Whats wrong with this line?


public class CLASSNAME extends JFrame, TimerTask implements ActionListener, Runnable
{
//constructor
}

I am more interested in extending the TimerTask but my code triggers lots of 'cannot resolve symbol' when I remove JFrame.

How could I fix this problem. I need to be able to extend JFrame and TimerTask.

Thanks
 
Don't get me started about those stupid light bulbs.
 
subject: timer class