Methods in contracts don't continually run, they execute when they are triggered via a transaction. A continually running contract would be seen as an attack on the network given its consumption of resources. Essentially, the gas limit for execution would be reached and the execution would be reverted.
I know recursive calling exhausts the gas, my question is that how can i make the function not exit till a condition is met. Something like stop() in thread
@trial2try So effectively you want while (!x) {//do something}. This will simply consume gas until the gas blocklimit (5000000) is hit and then throw reverting any changes that were made.
The whole point of gas is to ensure that code stops running.
Comments
while (!x) {//do something}
. This will simply consume gas until the gas blocklimit (5000000) is hit and then throw reverting any changes that were made.The whole point of gas is to ensure that code stops running.