/** * Author: Josiah Yoder et al. * Class: SE2811-011 * Date: 12/16/13 8:27 AM * Lesson: Week 3, Day 1 */ package example3_1; import java.util.*; public class Example implements Runnable{ public static final int SIZE = 10000000; List list; public void sortArray(List list) { // O( n Log(n) ) Collections.sort(list); } public void createList() { list = new LinkedList(); Random generator = new Random(); for(int i = 0; i < SIZE; i++) { list.add(generator.nextDouble()); } } public static void main(String[] ignored) { Example ex = new Example(); ex.createList(); System.out.println("main: Done creating list"); Thread thread = new Thread(ex); thread.start(); Thread thread2 = new Thread(ex); thread2.start(); for(int i = 0; i < SIZE; i++) { Math.sqrt(i); } try { thread.join(); } catch(InterruptedException e) { System.out.println("We were interrupted"); } System.out.println("main: I'm done! Bye!"); } public void run() { System.out.println("run: Starting sorting list"); sortArray(list); System.out.println("run: Done sorting list"); System.out.println("run: I'm done! Bye!"); } }