@Override
    protected void sort(final int[] a) {
        index.set(0);
        ArrayList<Callable<Void>> list = new ArrayList<Callable<Void>>();
        for (final int i : a) {
            Callable<Void> thread = new Callable<Void>() {
                @Override
                public Void call() {
                    try {
                        Thread.sleep(i*50);
                        synchronized (this) {
                            int where = index.getAndIncrement();
                            set(i, where);
                            
                            if (where + 1 == a.length)
                                sorting = false;
                        }
                    } catch (InterruptedException ex) {
                        Logger.getLogger(TimeSortingMethod.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    return null;
                }
            };
            list.add(thread);
        }
        
        ExecutorService ex = Executors.newFixedThreadPool(a.length);
        
        try {
            ex.invokeAll(list);
        } catch (InterruptedException ex1) {
            Logger.getLogger(TimeSortingMethod.class.getName()).log(Level.SEVERE, null, ex1);
        }

        while (sorting);
        
        ex.shutdown();
    }