# Sort array using 2 thread

• 04-23-2012
zooro
hi all i need ur help in how i can .....

sort array using ,,,, 2 threads...

Code:

``` public class Sort {      public static void main(String[] args) {                  int[] array = {3, 4, 12, 6, 7, 2, 3, 23, 1, 0, -9};                int i;                                              for (i=0;i<array.length;++i) {            System.out.print(" " + array[i]);                      }                System.out.println("");          int[] result = new int[array.length];        // what i have to do here                  for (i=0;i<result.length;++i) {            System.out.print(" " + result[i]);                    }                System.out.println("");      }  }```
• 04-23-2012
iMalc
Hmm...
Posting in the wrong forum - tick. (This is Java? code I think, certainly not C!)
Complete and utter lack of capitalisation - tick.
Horrible code formatting - tick.
Trying to solve a ridiculous problem - tick. (It would probably take more time to start a second thread than to just sort 11 numbers in one thread)

Am I going to just move right along and ignore this thread? - one big fat tick!
• 04-23-2012
zooro
How i write Java application that sorts an array of integers using two threads. The rst thread
sorts the rst half of the array, the second the second half. Both threads should run in parallel.
After the threads have nished their work, the two halves must be merged into one sorted
array.

Code:

``` public class Sort {     public static void main(String[] args) {          int[] array = {3, 4, 12, 6, 7, 2, 3, 23, 1, 0, -9};                int i;                                              for (i=0;i<array.length;++i) {            System.out.print(" " + array[i]);      }                System.out.println("");          int[] result = new int[array.length];            // what i have to do here                    for (i=0;i<result.length;++i) {            System.out.print(" " + result[i]);                    }                System.out.println("");      }  }```
• 04-23-2012
claudiu
Are you deaf???? This is the C Forum, nobody cares about your Java rubbish
• 04-23-2012
laserlight
Moved to Tech Board.
• 04-23-2012
memcpy
The whole basis of this thread is dumb. Why would you need threads to sort an array of integers? Even in a suitably sized array, the work needed to start/stop/communicate between the threads, would be more than using only one.

Quote:

hi all i need ur help in how i can .....

sort array using ,,,, 2 threads...