Click to See Complete Forum and Search --> : Timer Thread in servlet


February 22nd, 2000, 06:48 AM
Hi,

I'm creating a game servlet. The game is supposed to be played only within specific time-limits. Can I have a timer thread inside the servlet which continously keeps track of the time and as soon as the time limit is reached informs the player about the same?

The problem that i have here is not so much of a time-out issue where i have to check the "last accessed time". the user is very much active ... he is playing the game and i want to stop him in between at a particular scheduled time. so i want a thread to keep running.. which compares the current time with the scheduled time and as soon as scheduled time arrives, i want to give the user a message that the game play time is over.

If I could get some sample code of threads being spawned from servlets ... that'll be great. Any suggestions on how I could implement this are awaited eagerly.

Thanx in advance.

February 25th, 2000, 03:39 AM
hi,

I guess u r creating a web based Game. There is no problem creating a thread in the servlet. U can just go ahead by adding a thread
data member in servlet class & Instantiating in the init and do all the tricks. but the real problem is that u can not send a interruption
or a call back to the client becoz HTTP protocol is a request response paradim. One obscure solution would be to use RMI to make
a callback to the client. Hope u can take the further directions from here