I want to implement an Anytime k-NN classifier but I cannot find a way to call the "classify(...)" method for a specific amount of time, suspend it, get the available results before the method was suspended, resume the method for a specific amount of time, suspend it, get the available results before the method was suspended, and so on... I use a data structure for getting approximate results. While the algorithm traverses the data structure, it will encounter the actual training data vector, eventually.
public class AnytimeKNN{
 public int classify(queryPoint, k){
   class_label;
   1. Assign an initial value to 'class_label'.
   2.while(not actual training data vectors are encountered){
     1. traverse the data structure
     2. assign a new value to 'class_label'
    }
  }
}
I want to call the 'classify(..)' method from a main method in the following manner:
- Start the method 'classify(..)'
 - Pause the method 'classify(..)' when initial value to 'class_label' is assigned.
 - Get the initial label
 - Continue the method 'classify(..)' for X amount of time
 - Pause the method 'classify(..)'
 - Get the new 'class_label'
 - Resume the method 'classify(..)'for X amount of time an so on....
 
Thanks in advance!