Computer Science Canada Running a thread for a specific amount of time |
Author: | mrfungu [ Sun Jun 08, 2008 2:51 pm ] |
Post subject: | Running a thread for a specific amount of time |
Im trying to make a boggle game that will only allow user input for 3 minutes. How do i use the interrupt() to do this?.. or is there a better way of doing this? the java timer class? thanks. |
Author: | syntax_error [ Sun Jun 08, 2008 5:13 pm ] |
Post subject: | RE:Running a thread for a specific amount of time |
I personally have not used the interrupt();however, the timer class seem it can do your job for you as well as the interrupt(). To me it really wont make any difference using either of the methods. depends on what you want to do after |
Author: | mrfungu [ Sun Jun 08, 2008 5:20 pm ] |
Post subject: | Re: Running a thread for a specific amount of time |
what im trying to do is just limit the user to only 3 minutes of playing time.. and after show how many words they got right and return to a menu. if i were to use a timer class.. how would i do it. ive been experimenting and i can only get the game to start playing AFTER 3 minutes.. not during those 3 minutes. what should i do instead? |
Author: | syntax_error [ Sun Jun 08, 2008 5:31 pm ] | ||
Post subject: | RE:Running a thread for a specific amount of time | ||
if you wish to use the timer class then do it something like this :
Edit: code tags werent working... |
Author: | mrfungu [ Sun Jun 08, 2008 6:07 pm ] |
Post subject: | Re: Running a thread for a specific amount of time |
ok im using the timer class. and its working. but i cant get anything to happen after the time. can you look at the code attached. thanks |
Author: | mrfungu [ Mon Jun 09, 2008 6:24 pm ] |
Post subject: | Timer Class programs |
i added the timer/play method into my main program. it seems to be working except for the same small problem. even after the timer ends and continues to the next method, the program continues to ask for user input. thanks. |