mardi 3 mars 2015

Java: Sorting with more than one thread



Trying to sort an input file with more than one threads and write back the output. Each line of the input file contains an object. Something like this:



List<Person> list = new ArrayList<Person>();
list.add(new Person(1L, 10, 1, 1960));
list.add(new Person(4L, 4, 5, 1978));
list.add(new Person(8L, 9, 17, 1986));
list.add(new Person(7L, 2, 15, 1971));
list.add(new Person(2L, 7, 1, 1971));
Collections.sort(list);
printList(list);


Now I am trying to run the same operation with 3 threads and write/print it back in following format:



Thread 1: 1 10 1 1960
Thread 2: 7 2 15 1971
Thread 1: 2 7 1 1971
Thread 1: 4 4 5 1978
Thread 1: 8 9 17 1986



Aucun commentaire:

Enregistrer un commentaire