Why the ConcurrentModificationException?

Hello my Java friends.
When executing the following code:
143        // Create the Clique's medium.
144        this.medium.addAll(ownerIdentity.getConnection().getMediaProfileNode().flattenMediaProfile());
145        for(MI i:candidateIdentities){
146            Set<SourceMediaProfile>memberMedium=i.getConnection().getMediaProfileNode().flattenMediaProfile();
147
148            for(SourceMediaProfile ownerMediumMediaProfile:this.medium){
149                if(memberMedium.contains(ownerMediumMediaProfile)){
150                    continue;
151                }
152                this.medium.remove(ownerMediumMediaProfile);
153            }
165        }I get the following excetption:
java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:810)
        at java.util.HashMap$KeyIterator.next(HashMap.java:845)
        at cliquespace.core.agentdevice.source.SourceClique.<init>(SourceClique.java:148)The flattenMediaProfile method has the following code:
114    public Set<SourceMediaProfile>flattenMediaProfile() {
115        Set<SourceMediaProfile>mps=new HashSet<SourceMediaProfile>();
116        mps.add(this);
117
118        MPN mpn=null;
119        try{
120            mpn=(MPN)this;
121            Collection<SourceMediaProfile<CS,?extends MediaProfileIdentifier,MPN,C,I,MI,P,OP,CL>>mpc=mpn.getParentMediaProfiles();
122            for(SourceMediaProfile p:mpc){
123                mps.addAll(p.flattenMediaProfile());
124            }
125        }catch(ClassCastException cce){/*Do nothing.*/}
126
127        return mps;
128    }Now, I can probably create arrays to do what I'm trying to do with these collections, but I think I might be doing something wrong with the collection objects, and, rather than remaining ignorant, I would like to take this opportunity to find out what that might be.
Your considered advice would be well received.
Thanks,
Owen.

Owen Thomas wrote:
jverd wrote:
Owen Thomas wrote:
One must assume that no response implies that there is no substantial difference, That's a pretty silly assumption.No it isn't.Yes, as a matter of fact it's totally ridiculous to think that the only reason someone doesn't respond to you is because you were correct. Believe it or not, people do have lives outside this forum, and proving something to you is not the center of our respective universes.
and that matters pertaining to whether one chooses to use an iterator in a while loop or a copy of a collection in a foreach loop are... trivial matters of style.There's also the fact that one creates a copy of the collection and the other does not. That could be a significant cost in time and space.Surely an iterator must also have a collection over which it iterates. Yeah, the collection that already exists. What you're doing is creating an additional one beyond that, which is totally unnecessary here.
If not, how does the creation of an iterator enable me to "iterate" over the collection when the size and content of the collection may change?Um, that's kind of the point of ConcurrentModificationException. If a modification occurs other than via the Iterator, then the Iterator's invariants may not hold, so that Iterator may not have an accurate picture of the state of the collection, which is why the exception is thrown.
Providing me with a link to an article that discusses this would be appreciated.The javadocs for Collection and Iterator would be a start. You'll notice they say that the Iterator iterates over the Collection, and does not say anything about making a copy of it.

Similar Messages

  • Why the 2LIS_08TRTK extractor can not get  all data

    Hello, BW Gurus.
    Why the 2LIS_08TRTK and 2LIS_08TRTLP extractors can not get all data. I had used the RSA3 and get 10 registers, when a check at the VTTK table I had 20 registers, I didnt use filters at RSA3, could you help to know what happen o correct it.

    Is it because
    <i>
    Shipment documents and their dependent objects (shipment stages as well as shipment items [deliveries in the shipment]) are only extracted into BW when the Shipment completion status has been set.
    This is necessary because the numeric values that result from the delivery documents are only established at the time. If the data were already stored earlier in BW, the shipment data would not be updated if the delivery notes were changed in BW.
    </i>
    - from oss note 573470.

  • Why the default value is not the Oracle recommended?

    Why the default value is not the Oracle recommended?
    In Oracle 10g, the default alocated unit of Oracle ASM is 1MB. But the Oracle ducumentation states that "To ensure a higher probability of one
    logical I/O resulting in no more than one physical I/O, the minimum stripe depth should be at least twice the Oracle block size". ---See Performance Tuniing Guide (10g10.2 Page8-3.
    It's inconsistent. What is right way?

    >
    Why the default value is not the Oracle recommended?
    In Oracle 10g, the default alocated unit of Oracle ASM is 1MB. But the Oracle ducumentation states that "To ensure a higher probability of one
    logical I/O resulting in no more than one physical I/O, the minimum stripe depth should be at least twice the Oracle block size". ---See Performance Tuniing Guide (10g10.2 Page8-3.
    It's inconsistent. What is right way?
    The default database blocksize of 10g is 8k.
    >
    8 * 128 = 1024
    128 >= 2
    At least twice the size does not mean exactly the doubled size.
    There is no contradiction between the documentation and your observation in this case.
    Kind regards
    Uwe
    http://uhesse.wordpress.com

  • Why the 'LIKE' operator takes so much time to run?

    I have a table T with 3 columns and 3 indexes:
    CREATE TABLE T
    id VARCHAR2(38) NOT NULL,
    fid VARCHAR2(38) NOT NULL,
    val NVARCHAR2(2000) NOT NULL
    ALTER TABLE T ADD (CONSTRAINT pk_t PRIMARY KEY (id,fid));
    CREATE INDEX t_fid ON T(fid);
    CREATE INDEX t_val ON T(val);
    Then I have the following two queries which differ in only one place - the 1st one uses the '=' operator whereas the 2nd uses 'LIKE'. Both queries have the identical execution plan and return one identical row. However, the 1st query takes almost 0 second to execute, and the 2nd one takes more than 12 seconds, on a pretty beefy machine. I had played with the target text, like placing '%' here and/or there, and observed the similar timing every time.
    So I am wondering what I should change to make the 'LIKE' operator run as fast as the '=' operator. I know CONTEXT/CATALOG index is a viable approach, but I am just trying to find out if there is a simpler alternative, such as a better use of the index t_val.
    1) Query with '=' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val = '3504038055275883124';
    2) Query with 'LIKE' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val LIKE '3504038055275883124';
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=99)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=1 Card=1 Bytes=99)
    2 1 INDEX (RANGE SCAN) OF 'T_VAL' (NON-UNIQUE) (Cost=4 Card=12)

    I will for sure try to change the order of the PK and see whether there will be any impact to the performance.
    In our application, val is much closer to a unique value than fid. In the example query, the execution plan showed that the index on val was indeed used in the execution of the query. That's why the 1st query took almost no time to return (our table T has more than 6 million rows).
    I was hoping the 'LIKE' operator would utilize the t_val index effectively and provide similar performance to the '=' operator. But apparently that's not the case, or needs some tricks.

  • My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad one.

    My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad .

    Are you using the Sky Go app to try and watch it ? If so are you logged in with your Sky account ?
    If you are using the app then you could try closing the app completely and see if it works when you re-open it : from the home screen (i.e. not with Sky Go 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Sky Go app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Status keeps changing from invisible to online: why the issue is ignored?

    There is a serious issue raised in the parallel thread, which is critical for many people: "Status keeps changing from invisible to online" (initiated on ‎16-11-2014 by b.agne, Mac section). In short, when starting using a device, the Skype status changing from "invisible" to "online" - sometimes just for a moment, though enough for others to notice you. These affects very much any type of devices. I am sure the issue has already led to multiple personal crisises and potentially financial losses due to buseness partnership issues (I came close to that myself, and now use anything but Skype for business). The question is: WHY the issue is completely ignored by Skype, Microsoft and expert comunity? Please post the solution if anybody knows how to fix the issue, or suggest how to make Microsoft to know that it should be fixed. Kind regard...

    Hi, I also have the same issue. I change the status to Invisible and a later on it is already as "Online", without having even touched/opened Skype. The only way that I see this may happen is that I have the app installed on the smartphone, but before it never had this issue, but from some month ago it started. Any correction or suggestion to work around this issue? Regards

  • HT5312 Hi I'm just wondering does any one know why the email to reset ur password hasn't came to my email address its been 2 days and I have been trying since No Emails ?

    Hi I'm just wondering does any one know why the email to reset ur password hasn't came to my email address its been 2 days and I have been trying since No Emails ? anyone know what happening ?

    Either it ended up in a spam filter or it isn't being sent to that address. If you can't find it, use the link in the 'Additional Information' section of that article to contact the iTunes Store staff.
    (88597)

  • Reasons why the E72 is NOT a 'smartphone'

    Contrary to what Nokia says in its marketing blurb and what the dealer claims, the Nokia E72 (and by inference, others in its ilk) is NOT a 'smartphone' by any stretch of the mind.  Yes, the E72 (and its predecessor the E71 and to a lesser extent the E63) are designs of beauty, good form factor, full QWERTY keyboard, brilliant screen, good camera and wonderful media compatibility features.  But a 'smartphone' is more.  The following are some reasons (having owned - and regretted big time - an E72 for the past 2 weeks:
    1. Top of my complaints list is the fact that the E72 does not have a good desktop suite.  The Nokia PC Suite that it ships with is a poor substitute.  For one, it merely allows the phone's contents to be viewed on a PC screen; it does not allow for the phone's data to be viewed or manipulated offline.  What this means is that the E72 must be connected to the PC for you to be able to see the contents.  What a 'smartphone' needs is the ability for its desktop suite software to be able to be used even when the phone is not connected to the PC (ie offline). This requires a full copy of the phone's data to be stored on the PC and one is able to view, change, edit, etc this data.
    Reasons why one wold want to work offline on the PC are many.  Firstly, it lets you edit the data on the PC (much easier to work on a full PC than on an E72). You can input all your contacts data, etc on the PC then sync to the phone.  Similarly, other data (such as diary events, notes, etc can be authored on a PC and then uploaded on to the E72.  Additionally, one can use the PC Suite software as your main PIM (personal info management) software.  But I suppose Nokia doesn't want people to be able to do that.  What a shame, if that's what the modern day executive needs then he'll just go elsewhere.
    Another reason why the PC Suite software should allow full data manipulation is ... what if your phone is lost, how would you access all your info (contacts, calendar events, memos, notes, etc)?  Even if you have a daily backup, the Nokia user would actually need to acquire another phone (similar model or equivalent) and then do a restore.  Until then, the backup file is of no use (because it cannot be viewed or manipulated).  Such backup strategies (in proprietary flat files) are from the dark ages of computer technology!  Nokia still believes it is cutting edge!
    2. Nokia's PC Suite software is a joke.  Not only does it require that the phone is connected to the PC for it to work, it actually handles data quite differently from the way the phone itself handles the same data!  You can change the fields on the phone but not on the PC Suite, eg you can edit the field on the phone from "Mobile" to "Mobile 1", you can create a new field called "Mobile 2" but on the PC Suite, all you get is the standard "Mobile" and the second mobile field you create is not found! Wow, what synchronisation!
    3. On the phone itself, a true 'smartphone' gives its user a multitude of options to do things his/her own way.  In calendar events mode, I may want to set alarms 15mins before or 30 mins after!  The E72 only allows before, that too only with a set of predetermined figures - ie I cannot set an alarm 23 mins before.
    For some events, I may want to repeat the event and its related alarm on a weekly, monthly or annual basis.  A professor may want to set a weekly alarm (starting from week 1 of the semester to week 14 of the semesster) for his lectures.  Another person may want to set an alarm on a certain day of the month for his loan repayment to the bank.  The Nokia allows you to set an annual anniversary alarm only.  I cannot set an alarm for an event 3 days ahead (say, to give me advance notice to buy a present for a loved one!)
    When editing calendar events, if you change a field but then decide to not keep the new figure, there is no option to cancel. Only the DONE button is present. You have to save (done) then re-edit the field. Silly.
    Similarly the Snooze buttin ought to give the user flexibility to put the alarm off for any set of time.  The phone may remind me of an upcoming event say 4 hours beforehand, I then need to put if off (snooze) for say an hour before it reminds me again.  That's what a 'smartphone' does, remind you politely like an english butler!
    4. The synchronising cable that Nokia ships with the E72 is another joke - its no longer than 6 inches long. Coupled with the requirement that the phone must be hooked up to the PC when doing any work on the PC Suite (see items 1 & 2 above), what if there is an incoming call? How do you answer the call with a 6 inche cable connecting the phone to the PC?  Sure Nokia want's to make savings, but it should be practical.
    The above are the main grouses that I have with the E72.  As any reader can aappreciate, they are all related to the software side of the phone.  At the moment - and with my unit being still new - I have not come across any issues related to the build quality. Yes the design of the battery cover seem flimsy. Its ok so far but I can see its not going to last that way for very long. Yes there is a bit of light leak directly under the Home key but I can live with it. The rear battery cover smudges easily and is a pain to keep clean, but hey, you can't have it all good.
    But as far as the software side is concerned, yes, I do expect it to perform well in handling my data.  We live in a modern world where most of us have an information overload in our daily lives.  That's why we look forward to a 'business smartphone' - a device that is better than a personal assistant and one I can carry in my pocket.  But when we have major global corporations such as Nokia promising you an 'advanced business smartphone' that actually falls three steps short, then I believe the public is being cheated for good.
    I hope other readers would read this post and are better informed about what kind of device they'd be getting should they decide to purchase an E72.  I also realise that Nokia may decide to edit (or even delete entirely) this post, but hey, if that happens, then I'd be promptem to post a copy of this review in a dozen other public forums.
    Have a great day!
    There ought to be laws out there on the use of the term 'smartphone'

    You are correct, well done - it is my view.
    But no, I am disabled and don't work for anyone, but I was a programming consultant.
    If I'm buying or bought anything in the past such as an E71 or E72 then I make sure it can do what I need it to before hand. The E71 surpassed my requirements.
    Mine came with a USB cable over a meter long, however I use bluetooth and need to do nothing - if my PC is on it knows my phone is there and visa versa without me doing anything (smart!).
    The phone can access any of my PC files I require using the phone even when I am out and the PC is switched off. The phone tells me which bus stops to get off at and which way to go when I do. The phone can manage all my calls right down to tailoring for specific numbers and depending on my GPS location do different things. I can automatically order my repeat prescriptions from anywhere and watch live TV or stream my favourite radio stations wherever I am. I can use msn or any messenger, wherever I am - I could go on and on - my phone is definitely 'smart'.
    Ovi is similar to PC suite but much more. You can sync contacts with the ovi server and then access them from any PC. I don't need that functionality so I don't know it very well but I have used it a few times. Ovi is Nokia's mobile web service, go to 'my nokia' to find out, its not difficult.
    I have no need to read your post again, none of what you said justifies the heading you gave this thread.
    If your beloved Palm is so great then go buy another one, why would we be bothered about them in this thread.
    Bottom line is this, you have NOT given any good reasons why the E72 (or any E series phone) 'is NOT a smartphone'. What you believe we think about what is excellent is irrelevant.
    E71-1(241.04) RM-346 300.21.012

  • Hi, can someone please tell me why the spell check in pages doesn't work. I went to preferences and enabled this auto spell checker and have set the language to british english. But still it doesn't work while it works perfectly in TextEdit.

    Hi, can someone please tell me why the spell check in pages doesn't work. I went to preferences and enabled this auto spell checker and have set the language to british english. But still it doesn't work while it works perfectly in TextEdit.

    Inspector > Text > More > Language
    Only applies to selected text, like making it a particular font.
    It is not a setting that sticks. If you continue to paste in text from elsewhere particularly the Internet it will have a different or None language set to it. You need to select it and make it B.E.
    Peter

  • Can anybody help me in finding the reasons why the time of email received are different from the one on my macbook which time is correct

    Hi
    Can anyone help me in finding the reason why the date on e=mail reced is different from the one on my MacBook eventhough it is correct
    Thanks

    Try this...
    Triple click anywhere in the line below to select it and press Ctrl+C to copy it.
    cmd /k netsh winsock reset
    Press the WinLogoKey+R to open the run dialog, then Ctrl+V to paste, then press enter/return.
    You should get something similar to this:
    Reboot the computer and the problem should be resolved.
    If it doesn't work then perhaps a full tear down and rebuild of iTunes will fix things. See Troubleshooting issues with iTunes for Windows updates for details.
    tt2

  • Goodnight. as you know apple has evolved considerably until today but there are people who do not have ability to buy new products. in my case I would like to know why the apple do not let the iphone 3g update to iOS 4.3 as are several applications that c

    goodnight. as you know apple has evolved considerably until today but there are people who do not have ability to buy new products. in my case I would like to know why the apple do not let the iphone 3g update to iOS 4.3 as are several applications that can not put on my iphone 3g due to this reason. Why does not Apple make a repository with applications for ios 4.2.1? or else do not work in an update to ios 4.3 on iphone 3g?

    This has nothing to do with Apple, as Apple does not make the apps.
    This is the decision of the app maker.
    Contact those app makers and ask them why they do this.

  • Why the oracle XML parser "parses" the DTD comments?

    Hi all,
    I always use the header
    <?xml version = '1.0' encoding='ISO-8859-1' ?>
    to be able to use foreign characters in the XML documents.
    The oracle xml parser handles this correctly.
    My problem is, when I write comments inside the DTD, the
    parser reports "Invalid UTF8 encoding".
    Why the parser "parse" the comments? (protected by <!-- and -->)
    How do I say that the DTD encoding is different from UTF, like
    ISO-8859-1?
    Example of a correct DTD and corresponding XML, reporting
    problems, related to the 2nd comment in the DTD specification,
    written with ISO-8859-1 characters.
    The DTD:
    <!-- valid.dtd -->
    <!ELEMENT valid ( B, C ) >
    <!-- valid represents the concept "Identificagco" -->
    <!ELEMENT B (#PCDATA) >
    <!ELEMENT C (#PCDATA) >
    The XML:
    <?xml version = '1.0' encoding='ISO-8859-1' ?>
    <!DOCTYPE valid SYSTEM 'valid.dtd'>
    <valid>
    <B>How are you, Conceigco</B>
    <C>I'm fine, thank you.</C>
    </valid>
    The parser output:
    [jgr@frontera test-dtd]$ java oracle.xml.parser.v2.oraxml -v
    valid.xml
    Error while parsing input sourcevalid.xml(Invalid UTF8 encoding.)
    Thank you for any help.
    Jorge Gustavo Rocha

    I was wrong in saying that the attributes are not added to the element.My main aim is to add a array of elements to the root node.
    Is there a efficient manner in adding the elements , rather than adding them individually with the help of appendChild method.
    Thanks in advance.
    null

  • HP Color LaserJet CP2025 / Windows 7(64bit)-Why the printer does not print color letters??

    HP Color LaserJet CP2025  / Windows 7(64bit)-Why the printer does not print color letters??

    Could be a lot of reasons. First try to print a supplies status page- If that prints with color on it, you have a driver problem.

  • Why the heck  did Apples think it had  to change everything around in iTunes. If it's not broke, don't fix it. Can't find anything now.

    Why the heck did Apples  think that they had to revamp everything in  Itunes.
    What was on the left is now on the right side.  It wasn't broken, why did you have to fix it? Where is Home share hidden?

    Show side bar.  Now that's better, thx.

  • I dont know why the battery life of my iphone 4 is so low ! i really want to know how many hours i'll have if it's on standby. And how many hours if i use it normally for music and facebook (sometimes a little bit games)

    i dont know why the battery life of my iphone 4 is so low ! i really want to know how many hours i'll have if it's on standby. And how many hours if i use it normally for music and facebook (sometimes a little bit games) !!!

    to enhance your battery life, keep screen display to minimum, set screen lock automatically after 1 min, select internet notifications to off.

Maybe you are looking for

  • Placeholder for IN condition in database adapter

    I'd like to pass a parameter to a database adapter which will modify the "in condition" portion in a select. For example: select firstname from xxx where lastname in (#arg1) Is this the correct syntax? If so, what values will arg1 take? Something lik

  • Having trouble updating my itunes to version 10

    i'm having trouble with updating my itunes to version 10

  • Gantt Chart in OBI Report

    Is there a way to generate a calendar representation of events in OBI, a Gantt chart? Basically want to be able to designate the events associated with a particular item based on the correpsonding start and end dates of events. At the top there will

  • Hide a field in a transaction

    Hello Experts, I need your help to solve this issue: I have created one sales transaction ,in that I have to hide one particular field. Please let me know how to do that If any body have step by step procedure please send . Thanks

  • Is the powerplug for Swiss the same as EU at the Ipad 2?

    or are there different plugs in the package?