Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Individual getFittest() {
- //Individual fittest = individuals[0];
- // Loop through individuals to find fittest
- /*for (int i = 0; i < size(); i++) {
- if (fittest.getFitness() <= getIndividual(i).getFitness()) {
- fittest = getIndividual(i);
- }
- }*/
- ExecutorService es = Executors.newCachedThreadPool();
- for(int i=0;i<5;i++)
- es.execute(new Runnable() {
- /* your task */
- Individual fittest = individuals[0];
- @Override
- public void run() {
- // A TUKAJ CEL FOR KLICEM NORMALNO?
- for (int i = 0; i < size(); i++) {
- if (fittest.getFitness() <= getIndividual(i).getFitness()) {
- fittest = getIndividual(i);
- }
- }
- }
- });
- es.shutdown();
- try {
- boolean finshed = es.awaitTermination(3000, TimeUnit.MILLISECONDS);
- // all tasks have finished or the time has been reached.
- } catch (InterruptedException e){
- System.out.println("Thread interrupted!");
- }
- // KAKO VRNEM OD ABSTRACT CLASSA
- return ???;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement