Choose what amount of core I want to use

0

It could help me in something, I need to execute this code but choosing how much core I want to use from my pc, this is to determine the search time, for my case I have four core and I need to see what time it takes to search for a file.

Thanks

package buscarfichero;

import java.io.File;
import javax.swing.JOptionPane;

/**
 *
 * 
 */
public class BuscarFichero {


public static void main (String[] args) {
    BuscarFichero objBuscarFichero = new BuscarFichero();
    String fichero = "";
    String directorio = "";

     fichero =  JOptionPane.showInputDialog(null,"Ingrese el nombre del fichero:");
     directorio =  JOptionPane.showInputDialog(null,"\nDirectorio de inicio de la busqueda: ");
    int availableProcessors = Runtime.getRuntime().availableProcessors();
    System.out.println (availableProcessors);

    objBuscarFichero.buscar (fichero, new File(directorio));
}

public void buscar (String argFichero, File argFile) {
    File[] lista = argFile.listFiles();

    if (lista != null) {
        for (File elemento : lista) {
            if (elemento.isDirectory()) {
                buscar (argFichero, elemento);
            } else if (argFichero.equalsIgnoreCase(elemento.getName())) {
                System.out.println (elemento.getParentFile());

            }

        }
    }
}
}
    
asked by Walter de jesus Teheran Tehera 26.03.2018 в 23:55
source

0 answers