Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Running a thread for a specific amount of time
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mrfungu




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
syntax_error




PostPosted: 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
mrfungu




PostPosted: 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?
syntax_error




PostPosted: 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 :

code:


do(

get input

if input == true {
 bhal
}
 
if !=true{
 foo
}

}while timer <= 3 minutes


Edit: code tags werent working...
mrfungu




PostPosted: 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


Background.java
 Description:
thread

Download
 Filename:  Background.java
 Filesize:  13.33 KB
 Downloaded:  297 Time(s)


Threadisppp.java
 Description:
main

Download
 Filename:  Threadisppp.java
 Filesize:  427 Bytes
 Downloaded:  80 Time(s)

mrfungu




PostPosted: 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.



BoggleGame.java
 Description:

Download
 Filename:  BoggleGame.java
 Filesize:  20.49 KB
 Downloaded:  1029 Time(s)

Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: