java - run() method doesn't get called from a Runnable implementation -


i'm having trouble runnable , thread implementations. have abstract class, can not modified:

abstract class ordenador {      ...      protected ordenador(string nombre, int[] array) {         ...     }      protected void escribir() {         ...     }      protected abstract void ordenar();  } 

and sort algorithm inherit class above , implements run() method, call sorting one.

class burbuja extends ordenador implements runnable {      protected burbuja(string nombre, int[] array) {         super(nombre, array);     }      protected void ordenar() {         ....     }      public void esperar() {         try {             thread.sleep(1000);         } catch (interruptedexception ex) {             ex.printstacktrace();         }     }      public void run() {         this.ordenar();     } } 

finally have main class creates random array , create new burbuja object sort array. problem when calling b.join() array stay same de ordenar() method doesn't called.

class aplicacion {      public static void main(string[] args) {         ...          burbuja burbuja = new burbuja("burbuja", array);         thread b = new thread(burbuja);         ...          try {             b.join();             s.join();             ... more sorting algorithms...         } catch (exception ex) {             ex.printstacktrace();             system.exit(-1);         }          system.out.println("");         burbuja.escribir();        } } 

i tried modificating parts of code doesn't work neither.

you have call start() method on thread object

https://docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -