Results 1 to 2 of 2
  1. #1
    jdgallag is offline Member
    Join Date
    Oct 2008
    Rep Power

    Default help with concurrent modification exception

    I am sort of new to java, and I want to do things in a semi-functionaly way, just for fun. So I wrote a small library of static methods for listoperations, a functional style insertion sort, and then I got stuck on merge sort. I have written merge sort before in java, but I wanted to do it in a functional way. In the code I am going to paste below, I am almost certain that merge is working correctly. I have tested it up and down, with manually created lists. I am also certain that halve works correctly. All methods are static. The code I have for mergeSort is:

    Java Code:
    public static <t extends Comparable<t>> List<t> mergeSort(List<t> list){
    		//if (list.isEmpty()){
    		//	List<t> empty = new LinkedList<t>();
    		//	return empty;
    		if(list.size() <= 1){//was else if
    		//	System.out.println("aahhhh");
    			return list;
    			Pair<List<t>> pair = ListOps.halve(list);
    			List<t> firstH = mergeSort(pair.fst());
    			List<t> lastH = mergeSort(pair.snd());
    			return merge2(firstH,lastH);
    And I get concurrent modification exception. I am not using threads.

  2. #2
    jdgallag is offline Member
    Join Date
    Oct 2008
    Rep Power


    No problem. I was playing with a list in a static main class, that was being thrown all over the place. When I tested with real tests, everything works great.

Similar Threads

  1. Replies: 0
    Last Post: 04-05-2008, 10:10 AM
  2. Inventory Program modification help
    By badness in forum Java Applets
    Replies: 1
    Last Post: 01-17-2008, 05:24 AM
  3. Concurrent Applications
    By m@tqi in forum Advanced Java
    Replies: 1
    Last Post: 12-01-2007, 12:09 AM
  4. Replies: 0
    Last Post: 11-26-2007, 01:20 PM
  5. Concurrent Versions System (CVS)
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-02-2007, 03:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts