• Post Reply Bookmark Topic Watch Topic
  • New Topic

Run particular function for particular amount of time  RSS feed

 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I want to know how we can run any particular function for some particular amount of time?
In my application I have one function that find Latitude and longitude I want to run that function only for one minute.

Thanks in advance
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java has methods, not functions.

When you say that you want to run the method for one minute, do you mean that
-- the method executes a loop repeatedly, and you want to interrupt that looping after a minute?
OR
-- the method contains a blocking call which you want to timeout after a minute?

TellTheDetails or better still post a SSCCE
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Timer class within a loop. Check this link
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!