Is there any API or options wherein lines of codes are executed within a specified time.
code line 1
code line 2
code line 3
code line 4 ---- The code execution stops here itself without proceeding since the given time limit has ended.
code line 5
EndTimer<Current time+10 seconds>
thanks in advance
Joined: Apr 10, 2010
You could use Thread.sleep(ms) method. Here's a code snippet
but..perhaps i got it wrong..you want all the 5 lines to be executed within a time limit...
Run the code in a different thread, then use join:
There is no real way of actually terminating the thread though, so the code will continue in the background. Maybe interrupting the thread can help but I'm not sure.