Read files Callable Java Interface

0

I need to read certain files that are in a folder, each file has an operation for example 2 + 2, and when you finish that you can read the result, perform the operation and show your result in the console as something like this

Archivo1
2+2
4

I'm implementing it with the Callable interface

public class Micallable implements Callable<Integer>{

Integer value;

public Micallable(Integer value){
    this.value=value;
}

@Override
public Integer call() throws Exception {
    int total = 0;
    for (int i=0;i< this.value;i++){
        total +=i;
    }
    try{
        Thread.sleep(300);
    }catch(InterruptedException e){}
    System.err.println
    (Thread.currentThread().getName());
    return total;
  } 

}
    
asked by Sebastian Salazar 23.02.2018 в 20:10
source

0 answers