public void dispatch() {
        fillMarkerList();
        for (numOfThreads = numOfChunks / 2; numOfThreads > 0; numOfThreads /= 2, numOfChunks /= 2) {
            if (numOfChunks % 2 == 1) {
                oddFlag = true;
            } else {
                oddFlag = false;
            }
            mergeThreads = new MergeThread[numOfThreads];
            for (int i = 0; i < numOfThreads; i++) {
                if (i < numOfThreads - 1) {
                    int s1 = markerList.removeFirst();
                    int e1 = markerList.removeFirst();
                    int s2 = markerList.removeFirst();
                    int e2 = markerList.removeFirst();
                    markerList.addLast(s1);
                    markerList.addLast(e2);
                    mergeThreads[i] = new MergeThread(arr, s1, e1, s2, e2);
                } else if (i == numOfThreads - 1) {
                    if (oddFlag) {
                        int s1 = markerList.removeFirst();
                        int e1 = markerList.removeFirst();
                        int s2 = markerList.removeFirst();
                        int e2 = markerList.removeFirst();
                        int s3 = markerList.removeFirst();
                        int e3 = markerList.removeFirst();
                        markerList.addLast(s1);
                        markerList.addLast(e3);
                        mergeThreads[i] = new MergeThread(arr, s1, e1, s2, e2, s3, e3);
                    } else {
                        int s1 = markerList.removeFirst();
                        int e1 = markerList.removeFirst();
                        int s2 = markerList.removeFirst();
                        int e2 = markerList.removeFirst();
                        markerList.addLast(s1);
                        markerList.addLast(e2);
                        mergeThreads[i] = new MergeThread(arr, s1, e1, s2, e2);
                    }
                }
                this.addSource(mergeThreads[i]);
                mergeThreads[i].addListener(this);
                mergeThreads[i].start();
            }
            while (!allThreadsfinished());
        }
    }