--- /dev/null
+package edu.tamu.aser.rvtest.bubblesort;\r
+\r
+/**\r
+ * \r
+ * Created by IntelliJ IDEA.\r
+ * User: Alex\r
+ * Date: 11/06/2003\r
+ * Time: 13:29:18\r
+ * To change this template use Options | File Templates.\r
+ */\r
+\r
+import java.io.IOException;\r
+\r
+/**\r
+ * \r
+ * BubbleSort sorts an array by the Bubble sort algorithm\r
+ */\r
+public class BubbleSort {\r
+ // holds the array to be sorted\r
+ private final int[] arr;\r
+\r
+ /**\r
+ * getting the array to be sorted and it's size\r
+ * \r
+ * @param array The array to be sorted\r
+ */\r
+ public BubbleSort(int[] array) throws IOException {\r
+ arr = array;\r
+ }\r
+\r
+ /**\r
+ * Sorting the array by the bubble sort algorithem: Running 'size' times on\r
+ * the array, each time a thread is created that's supposed to bubble up the\r
+ * next biggest number not sorted yet. Since it is unknown which thread may\r
+ * finish 1st, and cause a bug, every thread runs from the biginning to the\r
+ * end of the the array, to correct possible mistakes\r
+ * \r
+ * @throws Exception\r
+ */\r
+ public void Sort() throws Exception {\r
+ final OneBubble[] bubbelesArr = new OneBubble[arr.length];\r
+\r
+ for (int i = 0; i < arr.length; i++)\r
+ bubbelesArr[i] = new OneBubble(arr);\r
+\r
+ for (int i = 0; i < arr.length; i++)\r
+ bubbelesArr[i].start();\r
+\r
+ for (int i = 0; i < arr.length; ++i)\r
+ bubbelesArr[i].join();\r
+ }\r
+\r
+}\r