Search Results

Search found 4 results on 1 pages for 'concurrentmodification'.

Page 1/1 | 1 

  • Removing Item from Collection / Changing field of Object

    - by x Nuclear 213
    public void searchOwner(List<Appointments> appts, String owner) { Appointments theOne = null; for (Appointments temp : appts) { if (owner.equalsIgnoreCase(temp.owner.name)) { System.out.println(temp.data); temp.setResolved(true); } } } public void checkRemoval() { for (Appointments appts : appointments) { if (appts.resolved == true) { appointments.remove(appts); } //Iterator method used before enhanced for-loop public void checkRemovalI(){ Iterator<Appointments> it = appointments.iterator(); while(it.hasNext()){ if(it.next().resolved = true){ it.remove(); } } } So far this is where I am encountering my problem. I am trying to check the arrayList of Appointments and see if the field (resolved) is set to true, however I am receiving an ConcurrentModification exception during the searchOwner method when trying to set resolved = to true. I've tried using an Iterator in checkRemoval instead of an enhanced for-loop however that didn't help either. I really only need to get the part where the appointment is set to true to work, the checkRemoval seemed to be working early before implementing the changing of the boolean resolved. Any help will be greatly appreciated, thank you.

    Read the article

  • synchronized block in JSP tag class

    - by Sudhakar
    Hi, I am trying to find answer for the following ,for the past couple of days ,but couldnt find comprehensive answer Problem Statement I have a custom JSP tag class which handles a web form submission ,captures data and write it to same file in the filesystem. As all web applications,this can be triggeredsimultaneosly ,and i fear that multiple threads would be in action handling each of the submission (we all know thats how Servlet works.) CODE synchronized (this){ final String reportFileName = "testReport.csv"; File reportDir = new File( rootCsDirectory, "reports" ); if(!reportDir.isDirectory())reportDir.mkdir(); File reportFile = new File (reportDir, reportFileName); logReport(reportFile,reportContent.toString()); } ISSUE: - A File object can be opened by one thread for writing and at same time another thread might try to access and fail and throw an exception So i thought of synchronizing (on the object ) should solve the issue , but read some where that jsp engine would have pool of jsp tag objects, so i am afraid that synchronized (this) wont work and it should be changed to synchronized (this.getClass())

    Read the article

  • how to remove ConcurrentModificationException

    - by maverick
    what is this exception and how to remove this in my problem i am creating an arraylist of objects, and after checking some condition,i want to remove some objects. but the program is giving this exception ConcurrentModificationException. how to remove this thanks in advance

    Read the article

  • How to do concurrent modification testing for grails application

    - by werner5471
    I'd like to run tests that simulate users modifying certain data at the same time for a grails application. Are there any plug-ins / tools / mechanisms I can use to do this efficiently? They don't have to be grails specific. It should be possible to fire multiple actions in parallel. I'd prefer to run the tests on functional level (so far I'm using Selenium for other tests) to see the results from the user perspective. Of course this can be done in addition to integration testing if you'd recommend to run concurrent modification tests on integration level as well.

    Read the article

1