What would happen if two concurrent threads try and remove ....

Hello,
I have a java test to give back tomorrow and I'm stuck on this question, could you help me please.
Question: What is the difference between java.util.Vectorand java.util.ArrayList?
I read everywhere that: The main difference between Vectors and ArrayLists is that Vectors are synchronized so any method that touches the Vector’s content is thread safe, which is not the case for ArrayLists.
This part is ok.
Now the second part of the question is:
What would happen if two concurrent threads try and remove the third object
of such a collection?
I don't know what to answer. I could tell that if the vector or arraylist is smaller than 3 il will return an ArrayOutOfBoundException but what happen if they are longer?
Thank you very much.

RaptorKiller wrote:
Hello,
I have a java test to give back tomorrow and I'm stuck on this question, could you help me please.
Question: What is the difference between java.util.Vectorand java.util.ArrayList?
I read everywhere that: The main difference between Vectors and ArrayLists is that Vectors are synchronized so any method that touches the Vector’s content is thread safe ...hm. hmmm...
I wouldn't say anything about Vector or its methods being thread safe.
Thing is, [Vector javadoc|http://java.sun.com/javase/6/docs/api/java/util/Vector.html|javadoc] does not state anything like that.
Rather opposite, javadoc says Vector hates concurrent modification just like any other non-concurrent collection: +"...The Iterators returned by Vector's iterator and listIterator methods are fail-fast: if the Vector is structurally modified at any time after the Iterator is created, in any way except through the Iterator's own remove or add methods, the Iterator will throw a ConcurrentModificationException... Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification..."+
This part is ok.I don't think this part is OK. I would stick with wording given in javadoc: +"Unlike the new collection implementations, Vector is synchronized"+ // synchronized does not necessarily mean thread safe, and Vector is the case proving that

Similar Messages

  • What would happen??  I used "import" and "useBean" for same bean...

    Hi, yes, I'm not a professional programmer (clearly)
    I used the import page directive and the jsp:useBean statement for the same bean in a jsp program I wrote.
    What's interesting is that the program works fine for me, storing values and retrieving them from the bean as I click through the different jsp pages.
    However, it doesn't work well for one of my friends, the values usually get lost as he clicks through the jsp pages.
    I then noticed I used both statements to refer to the same bean, is that why this is happening? Were two instances of the bean sometimes being created even though the useBean had scope = session?
    Something else, again, the program works perfect for me, not for him. We did a speed check using:
    http://helpme.att.net/dsl/speedtest/
    His speed was twice as fast as mine. Would that explain why he sometimes (almost always actually) lost values between the jsp pages?
    Below is the first few lines on each jsp page:
    <%@ page language="java" import="java.util.*" %>
    <%@ page errorPage="exception.jsp" %>
    <%@ page import="test1.UserData"%>
    <jsp:useBean id="user" class="test1.UserData" scope="session"/>
    <jsp:setProperty name="user" property="*"/>
    Thanks for any and all help,
    Robert

    The webcontainer creates a new cookie for each session so that it can keep track of each user session. If cookies are disabled, then sessions are been tracked by URL rewriting (a query parameter 'jsessionid' will be attached to the URL with the session ID as value).
    Opening a new browser instance (not a tab or a new window from within the currently running instance) would also trigger a new session being created.

  • What would happen if I reformatted?

    My computer has been having many issues since FiOS triple play was installed.  Also still have resolved IHA only showing internet and not TV and phone like it should.  So I was wondering what would happen if I reformatted my computer?  Would I lose anything?  Is there a file someone can direct me to incase I lose the driver to the router in process? 
    Also, another option is to uninstall everything verizon that is currently installed.  Thinking previous DSL information on my computer might be the culprit, but since I don't know what files belong to DSL and what files belongs to FiOS I figured I'd just remove everything verizon and start fresh.  
    What program/information does the Installation Tech use when installing FiOS in your home that's on that little white jump drive?

    I actually uninstalled/removed/deleted any and all reference to Verizon, IHA, and VZ in my computer files(that I could find and recognize as verizon files).  Then went to activate my FiOS.   Now, In Home Agent actually shows my TV and Phone as well as my internet(it would only show internet).  So I believe my guess was right that previous Verizon DSL files that remained on my computer were interfering with In Home Agent.    I'm pleased to have fixed the issue.    I have this "Resume FiOS activation" icon on my desktop that won't go away, no matter how many times I click it and apparently finish the activation.   And In Home Agent keeps asking me to update to the newer version.  I click yes, it reloads, asks again, click yes, reloads, asks again.   So I just click no.    Also In Home Agent keeps telling me that my password is incorrect.   I'll change it, the program will automatically insert the NEW password into the box, and it will say it's incorrect again.   Eish!  I want to bang my head against a wall right now! 
    Also, Verizon.com under my services still shows that my set top boxes are not activated,  and any widgets I try to apply don't show up on the TV.  As well as it only gives me the option of adding widgets to one STB, and not the other two.  As in, only one of my three STB's in the drop down box.  
    This all is prett silly as far as I'm concerned.   A lot of bugs and kinks in the system and no one at Verizon seems to know how to fix any of it.   I love the faster more reliable internet, more reliable TV, more phone features than I had for one price comparable to all three as separate services(Dish, DSL, Home phone).  But I am not in love with the technical problems for which there are no answers.  From anyone.    Thinking Verizon's going to have to up the ante to compensate for all the headaches that have been caused by technical problems.  Like a lower price.  I think I deserve a couple people's hourly wage for figuring out what 3 support techs couldn't. 

  • What would happen if I were to delete the primary email address linked to my Apple ID?

    I wish to completely de-activate my @hotmail email address in order to be left with just my @icloud email address becuase I would find life more managable that way.
    I found out that I cannot change my primary @hotmail email address linked to my Apple ID with an @icloud email address as it is an active, separate Apple ID (in itself with a separate purchase / download history etc)...
    Also I am aware that separate Apple ID's cannot be merged together...
    My question is: "What would happen if I were to delete the primary email address linked to my Apple ID?"
    Would I be able to keep and use my purchases, provided they are backed up on my Mac and authorised?
    Would I be able to update those transferred purchases even though the email address linked to the apple ID in which the app was bought no longer exists?

    You can change the primary e-mail address associated with your Apple ID, so long as it isn't a mac, me or icloud email.
    http://support.apple.com/kb/HT5621
    Your Apple ID account, regardless of the primary email, can never be 'deleted', just abandoned.
    You could always just switch between the two Apple IDs as needed, to access the different purchases.

  • What would happen if I used Recovery Disk?

    I've recently bought a new iMac (Core i5) that came with Lion pre-installed, but I needed Snow Leopard for all my older software e.g. Photoshop CS, so I got the sellers to install SL for me. Everything is fine.
    Out of curiosity I tried to see if I could run Tiger from my old G5 HDD which is connected via USB, but it didn't come up in the list when I did Restart + Option. However, what DID come up was an extra drive named "Recovery". I understand this is a separate Lion partition on my HDD - so, what would happen if I selected that via Restart + Option? Would it open Lion on my iMac so I could have a play around with it? And if it did, would I then be able to get back to SL and all my data, users, and settings, after I'd finished?
    I don't want to try it out without advice, in case Lion overwrites SL irretrievably.

    christopher rugby wrote:
    My question is this : can I safely restart from Recovery in order to just play around with Lion, or will starting from Recovery reinstall Lion over the top of SL on my main disk?
    If your machine only has SL and the Recovery HD, then the only thing you can do when booting into the latter is REINSTALL Lion on top of SL or do some basic things, but Lion isn't installed. Details in Recovery/ and About Lion Recovery.

  • What would happen if you put iOS 7 on an iPod 4th generation? Just out of curiosity.

    What would happen if you put iOS 7 on an iPod 4th generation? Just out of curiosity.

    It will not install you will get an error message if you try to force an install.
    iOS: Restore error 3194 or 'This device isn't eligible for the requested build'

  • Can anyone tell me what would happen if I left the photo field blank on the Cards app on iOS?

    I like one of the letterpress designs but i'd prefer if the photo did not exist on the inside cover.
    Does anyone know what would happen if I left it blank or of any way to remove it?
    Thanks

    Try here:
    iTunes Store: My credit card's security code or zip code does not match my bank's records
    Then try contacting iTunes
    Apple - Support - iTunes - Contact Us

  • What would happen if my mac os hard drive failed

    so i have 2 hard drives
    1 for windows bootcamp and 1 for mac
    as it is now, i boot to the windows boot manager then choose my copy of windows.
    what would happen if my mac os hard drive failed right now?
    would the computer still boot and be unaffected unless i tried to boot to mac?

    failure is usually not dead. It can be a bad sector, but usually it is a directory issue or just the partition table (but which require either quick or long format)
    if you have a workstation, you should clone both operating systems; you should not put them on the same hard drive. And you just use the clone you made for each (Paragon Clone OS for Windows $19; Carbon Copy is sharefare for OS X)
    both of those allow booting off the new hard drive while you figure what you want to do or what happened.
    If you only have two hard drives use the other drive bays.
    Basically NOTHING happens if you pull one or the other.

  • Can I stop migration assistant on my new MacBook pro midway through? What would happen?

    I started migration assistant on my brand new MacBook pro last night and I need to take one of the computers today, either my old dell laptop or the MacBook. Can I stop migration assistant? If so what would happen?

    Link for Download & Install & Setup & Activation problems may help
    -Chat http://www.adobe.com/support/download-install/supportinfo/
    OR
    Some download & install troubleshooting links
    -Comodo Security kills download http://forums.adobe.com/thread/1460361?tstart=0
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html
    -http://forums.adobe.com/community/download_install_setup
    -http://helpx.adobe.com/creative-cloud/kb/troubleshoot-cc-installation-download.html
    -http://helpx.adobe.com/x-productkb/global/errors-or-unexpected-behavior-websites.html
    -http://helpx.adobe.com/creative-cloud/kb/unknown-server-error-launching-cc.html
    -Server won't connect https://forums.adobe.com/thread/1233088
    -AND JUST FOR MAC USERS - Some 10.9.3 links
    -Mac 10.9.3 workaround https://forums.adobe.com/thread/1489922
    -more Mac 10.9.3 https://forums.adobe.com/thread/1491469
    -Enable Mac Root User https://forums.adobe.com/thread/1156604
    -more Root User http://forums.adobe.com/thread/879931
    -and more root user http://forums.adobe.com/thread/940869?tstart=0

  • HT3819 What if one device breaks down? What would happen to the itunes libraries in the other linked devices?

    For example, I turned on Home Sharing for two computers in my home. Therefore, the two itunes libraries contain the same data. However, if one computer got a virus and all its data has been wiped out, including my music, films on iTunes - basically, if the computer just broke down....What would happen to the iTunes library in the other computer? Would all its data be wiped out as well?
    Thanks

    Home Sharing lets you stream or copy media from one library to another. If you stream media only the source computer has a copy of the data. If that machine died you would lose the data. If you copy the media across then you have a backup. I don't offhand know if Home Sharing lets you copy ripped CDs as well as store purchases as I've never used it.
    I would recommend you have one master library that you sync all of your devices to and you back that up! Other computers can then stream content or you can make local copies.
    tt2

  • I just backed up my mac to an external hard drive using Time Machine. What would happen if I turn Time Machine off and then plug the external hard drive back into my computer?

    I just backed up my mac to an external hard drive using Time Machine. What would happen if I turn Time Machine off and then plug the external hard drive back into my computer?
    What I am ultimately wanting to do is make more room on my computer by backing up all of my files onto the external hard drive and then deleting them off of my computer. However, neededing to be able to retrieve them from the external hard drive later down the road.
    From what I have read and am trying to understand, is that I probably shouldn't have used time machine. I need to use the external hard drive like a basic flash drive where I can put things on and get things off without having it automatically update through time machine everytime I connect it to my computer.
    Not tech savvy at all and barely understand basics. I need very simple and easy to understand explanations.

    sydababy wrote:
    and then deleting them off of my computer.
    BIG BIG MISTAKE ..... youre making a linchpin deathtrap for your data trying to shove everything on a single fragile HD.
    Dont suffer the tragedy other people make, buy another or 2 more HD, theyre cheap as dust.
    The number of people who have experienced terror by having a single external HD backup is enormous.  One failure that WILL HAPPEN, and kaput,......all gone!
    Dont do it, its all about redundancy, redundancy, redundancy.
    follow here:
    Methodology to protect your data. Backups vs. Archives. Long-term data protection
    Deleting them off your computer is fine....having only ONE copy is extremely BAD.
    The Tragedy that will be, the tragedy that never should be
    Always presume correctly that your data is priceless and takes a very long time to create and often is irreplaceable. Always presume accurately that hard drives are extremely cheap, and you have no excuse not to have multiple redundant copies of your data copied on hard drives and squirreled away several places, lockboxes, safes, fireboxes, offsite and otherwise.
    Hard drives aren't prone to failure…hard drives are guaranteed to fail (the very same is true of SSD). Hard drives dont die when aged, hard drives die at any age, and peak in death when young and slowly increase in risk as they age.
    Never practice at any time for any reason the false premise and unreal sense of security in thinking your data is safe on any single external hard drive. This is never the case and has proven to be the single most common horrible tragedy of data loss that exists.
    Many 100s of millions of hours of lost work and data are lost each year due to this single common false security. This is an unnatural disaster that can avoid by making all data redundant and then redundant again. If you let a $60 additional redundant hard drive and 3 hours of copying stand between you and years of work, then you've made a fundamental mistake countless 1000s of people each year have come to regret.

  • What would happen if I turn off my backup and delete backup data From my device? Will it delete my music and everything for ever or just stay in the cloud but not on my device?

    What would happen if I turn off my backup and delete backup data From my device? Will it delete my music and everything for ever or just stay in the cloud but not on my device?

    If you have multiple devices backing up to the Cloud, you will see all of them listed. You would click on each device to change what is backed up from that device. You can then delete your individual back-ups.
    Once you have all your settings to your liking, you can then go back to Settings>iCloud>Storage & Backup, and click on Back Up Now (bottom of the screen) to create a fresh backup with your new settings.
    Cheers,
    GB

  • What would happen if I forgot to click on eject, before disconnecting ipod?

    Is it neccessary to click on the eject button before disconnecting my ipod? What would happen if I forgot? Would I lose all my music?

    Ejecting is so old school. I just unplug it like I have been doing for years. No problems yet. I figure that the hardware shouldn't be affected even if there is a little data loss and if it is, it's crap and I will take it back.
    I think the ejecting legend has become a remnant from old-school mac days that hangs around to keep you from unplugging while syncing. Shouldn't be a problem....at least from what I have experienced on Windows. I am not sure if Macs still require that ejecting stuff on external media...

  • What's the difference between client combo and server combo? Also, what would happen if I install both?

    what's the difference between client combo and server combo? Also, what would happen if I install both?

    One is for the base version of the Mac OS, the other is for the Server version. You can only install the one that matches your system.

  • If I uninstall iTunes, what would happen to my music?

    I have been having issues with my iPod showing up on iTunes and I was thinking maybe I should completely uninstall it and then install it again. I'm very paranoid and don't want anything to happen to my library if I were to do this though. What would happen?

    Nothing will happen to it.

Maybe you are looking for