Suppose I have following piece of code running by a thread:
public void logic()
{
//Step1
//Step2
//Step3
//Step4
...
...
//Stepn
}
Nowhere in this method the interruptible methods are called(like wait, sleep, join).And some steps are taking lot of times to execute. The reason might be anything other than blocking operations like (socket.read or read methods of file). And I want to ensure that if the entire logic method is not executed in say M seconds then the thread should be killed. What is the best way to achieve this?