![]() If (RepTypeObject.stringValue().equals(OWL.CLASS) || RepTypeObject.stringValue().equals(RDFS.CLASS)) Value ConsumableTypeObject=CStatements.get(uri).get(RDF.TYPE) Value RepTypeObject=RepStatementsAsHash.get(uri).get(RDF.TYPE) RepStatementsAsHash.get(uri).remove(RDFS.RANGE) Įlse if(RepStatementsAsHash.get(uri).containsKey(RDF.TYPE)) RepStatementsAsHash.get(uri).remove(RDFS.SUBCLASSOF) Įlse if(RepStatementsAsHash.get(uri).containsKey(RDFS.RANGE)) RepStatementsAsHash.get(uri).remove(RDFS.LABEL) Įlse if(RepStatementsAsHash.get(uri).containsKey(RDFS.SUBCLASSOF)) If(RepStatementsAsHash.get(uri).containsKey(RDFS.LABEL)) I googled it and also know that such error comes only when you try to modify on-going iterative variable, which I don't feel in my case. How to avoid ConcurrentModificationException in a single-threaded environment?īy using iterator's remove() function, you can remove an object from an underlying collection object.I am working on my code and getting "". These classes help us in avoiding concurrent modification exception. JDK 1.5 or higher provides with ConcurrentHashMap and CopyOnWriteArrayList classes.This is not an effective approach as the sole purpose of using multi-threading is relinquished by this. Another way can be locking the list by putting it in the synchronized block.In this way, we can work very well with small-sized lists, but this will deplete the performance if the array size is very large. Instead of iterating over the collection class, we can iterate over the array.To avoid the ConcurrentModificationException in a multi-threaded environment, we can follow the following ways. How to avoid ConcurrentModificationException in a multi-threaded environment? The message is later retrieved by Throwable.getMessage() and cause is later retrieved by Throwable.getCause(). This creates a ConcurrentModificationException with a detailed message and a cause. public ConcurrentModificationException(String message, Throwable cause).The cause is later retrieved by the Throwable.getCause(). This creates a ConcurrentModificationException with a cause and a message which is (cause=null?null:cause.toString()). public ConcurrentModificationException(Throwable cause). ![]() This creates a ConcurrentModificationException with a detailed message specifying the Exception.
0 Comments
Leave a Reply. |