Which collection shall I use (BlockingQueue or Synchronized List) ?

I need to use a thread safe queue in my app that is under high contention - there are 8 producer threads (writing data to the queue) and one consumer (consumer is only one and it is fast enough). MAX size of the queue is fixed (configurable though). Producers keep adding and consumer keeps deleting from the queue. I want to know which collection/approach should be the ideal choice :
1. ArrayBlockingQueue
2. LinkedBlockingQueue
3. LinkedList with synchronization impl
4. ArrayList with synch impl
Edited by: radiatejava on Feb 27, 2009 11:52 AM

1. Yes, normal queue semantics are followed (ie data always removed from head and added at the end only).
2. Saying that only BlockingQueue is the option is not correct. I can also opt for normal LinkedList and ArrayList with my own sync implementation like this :
//producer side
LinkedList Queue_ = new LinkedList();
synchronized (Queue_) {
while(Queue_.size() >= 10000) {
Queue_.wait();
Queue_.addLast(msgBuffer);
Queue_.notifyAll();
And similar thing can be done on the consumer side.
3. Lastly, pls keep in mind that LinkedList or LinkedBlockingQueue impls wrap the actual objects to be addded into another Node class objects thus creating lots of extra objects that needs to be GCed as well, making the performance not as desired as we expect (extra time is spent on GC).
I want to know if there is any performance comparision available between BlockingQueues and synch List implementations.

Similar Messages

  • Which collection shall I use ?

    Hi every one,
    I am just stuck with one problem , I want to have elements which can avoid duplicate and also maintain order. I am not able to find the solution...
    Thanks in advance..

    I am just stuck with one problem , I want to have elements which can avoid duplicate and also maintain order. I am not able to find the solution...Avoid duplicates => you want a set (mathematical concept), represented in the JDK standard API as interface <TT>java.util.Set</TT> (http://download.oracle.com/javase/6/docs/api/java/util/Set.html)
    "maintain order" => you probably merely want a <TT>SortedSet</TT> (http://download.oracle.com/javase/6/docs/api/java/util/SortedSet.html)
    Then browse the Javadoc to find one of the multiple classes that implement those interfaces.
    J.

  • Which activity shall i use to initiate a documentum workflow under ecm connector.

    which activity shall i use to initiate a documentum workflow under ecm connector.

    That's not something supported out of the box.

  • Which BIOS shall I use for " K8T Neo -FSR"??

    I bought  a MSI K8T Neo- FSR board yesterday. But when I looked at the MSI web site I haven't seen ...FSR board, I only see ...FS2R board instead. So which BIOS shall I download and flash? There is also no any explanation about FSR. My board carries the BIOS V1.1. On the other hand it writes this informatin on the board; " K8t Neo 6702 rev. 1.0"

    ...here's the product page...I found it the other day but I can't remember how   ...got lucky, I guess...  
    ...BIOS version?..I've always used Live Update in Windows...just follow the directions to the letter...there are beta versions available in the forums...the current one is getting good reviews...

  • How do you specify which email address to use in a group list?

    Hi All,
    I've got several group lists created in Address Book. When I want to send an email to a group using Mail I cannot specify which email address gets used for a person that has multiple addresses in Address Book.
    My process is as follows: create a new blank message, address the note to myself, move to the bcc field, click the "Address" button at the top of the message pane. When I click on a name that has multiple email addresses I can click on the one that I want, but when I click to another name and click back the previously selected address is highlighted again. It seems that the selection of the address won't 'stick'. Is there any way to force the selection? Also, I originally thought that the group list defaulted to the home address, but I noticed that some entries have their work address selected by default.
    Thanks for any help.
    -Chris

    Thank you, thank you, thank you!!! I knew there was an option to do that somewhere. For some reason I had it in my mind that you made those selections in Mail.
    Kappy wrote:
    Open Address Book and select a group. CTRL- or RIGHT-click on the group and select Edit Distribution List. You may then scan through the group members selecting the desired email address for each one with multiple addresses.

  • Choose which content type to use in sharepoint 2013 list using InfoPath 2013

    So, in my head it seems pretty simple and a feature that might be standard to InfoPath so much in fact I can't find anything on it... My goal is to a have one list where you can do a drop down or buttons to choose which content type to use.
    I will be royally disappointed if this is not possible. =(
    So, c'mon you giants of MS Support. Give me a happy answer.

    Hi Lincoln,
    According to your description, my understanding is that you want to use multiple content types in a list.
    For achieving it, you can do as the followings:
    Open the list.
    Go to List Settings->Advanced Settings.
    Under ‘Allow management of content type’, select ‘Yes’, click OK.
    In the Content Types section, click ‘Add from existing site content types’
    Then add the content types that you want to add, click OK
    Go back to the list, click ITEMS->New Item, then all content types are displayed in the drop-down list
    When you click an item, you can select the new item is created based on one of these content types
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Which collection should I use

    As I'm scanning an XML file gathering anchors, I'd like to associate the data with the file the anchor came out of. So there could be multiple anchors associated with a file, and that same file name could be an anchor itself in another file. I'd like to print this information out later like so:
    link: mysite.com/mycontent.htm found in pages: index.htm, content.php, etc.
    link: index.htm found in pages mycontent.htm, content.php
    This is all basically an effort to find dead links or redirects on my web site. Yes, I know there are tools out there that do this, but I'm trying to create this and learn some Java at the same time. Not to mention this tool does a lot of other things specific to my job. So, any ideas on what I could use and how?

    Also check this out:
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • Which 3G shall I use?

    Hi all, this is my first post on this forum and I am a new iPad owner and my first ever apple product and I am very impressed. This iPad is my girlfriends it's a 64gb wifi version but I am looking at getting myself a 64g 3G. I have seen that here in the uk the three network is offering the best price at £15 per month for 10g content. I am an orange user with my mobile phone but orange with the iPad seems expensive.
    Ant are you guys using? And how do you find it?
    Thanks in advance
    Message was edited by: Adie Hughes

    There's more to this than meets the eye.
    Biggest factor apart from cost is whether or not a network gives reasonable coverage in most places you'd want to use it regularly on the go, otherwise it's useless.
    I went with O2 as I get reasonable coverage on 3G for my iPhone and while not the best value, 3GB for £15 rolling monthly renewal with ability to cancel 24 hrs before seemed ok.
    I'm currently considering trying 3.
    O2 3G for iPad service has big shortcomings for me:
    Internet images (safari/e-mail links) are compressed by O2 servers and are extremely poor quality - full of artefact with reduced colour depth which really spoils the experience for me. I'm paying for 3GB quota - I want full quality images even if they use more of my data allowance.
    BBC iPlayer does not work on O2 3G currently.
    YouTube videos are extremely low quality over O2 - considerably worse than over wi-fi for the same content.
    Other posters suggest 3 does not compress images, and that iPlayer works, though YouTube quality may be reduced.
    Not sure about Orange/Vodafone, as few comments though I don't think Orange compresses images.
    One user noted a £150 'hidden charge' taken upfront by Orange, and he's still in dispute with them last time I read the thread - sounds like a one-off error but can't say for certain until he tells us the resolution.
    Also consider some of the plans include wi-fi access at one or more hotspots, some have none.
    I've already picked up a 3 microsim, but am put off by a convoluted setup process that sounds as though it's done via overseas call centre.
    AC

  • Which D2W shall I use ?

    I want to create a front end for a database holding information about different projects, the database will be simple and will be used on a web site people will be able to brows it on the web and an administrator will be able to add stuff. I would like the ability for record owners to alter just their own records but that is secondary, so would I use...
    Direct to web application
    Direct to web services application
    Web Objects application
    Display group application ?

    I am just stuck with one problem , I want to have elements which can avoid duplicate and also maintain order. I am not able to find the solution...Avoid duplicates => you want a set (mathematical concept), represented in the JDK standard API as interface <TT>java.util.Set</TT> (http://download.oracle.com/javase/6/docs/api/java/util/Set.html)
    "maintain order" => you probably merely want a <TT>SortedSet</TT> (http://download.oracle.com/javase/6/docs/api/java/util/SortedSet.html)
    Then browse the Javadoc to find one of the multiple classes that implement those interfaces.
    J.

  • Which system shall I use?

    anyone work inside sap knows which existing system has the MI SERVER COMPONENT installed?

    Hello Irene,
    MI 2.5 Server Component is shipped with WEBAS 6.40.
    You have to install ABAP and Java Stack. MI Server Part does not have to be deployed seperately. After installtion of WebAS 6.40 a few steps are nescessary. You will find them here:
    http://help.sap.com/saphelp_nw04/helpdata/en/bb/b670bbaa991845924982155b7c3726/frameset.htm
    In Mobile Engine 2.1 you also have to deploy the sync servlet and the Web Console to the J2EE on the MI server.
    This is not needed with WEBAS 640 and MI2.5.
    Regards
    Frank Brackmann

  • Which RFID shall i use??

    Hi ,
    I am a post grad engg student. I'm planning to build a RFID with WSN system that can monitor bus traffic inside spacious bus stations, and can inform administrators whether the bus is arriving on time, early or late. This information is then displayed on the
    different wireless displays inside and outside the bus station. I intend to keep RFID readers inside buses to identify stops [ the stops have tags]. the sensors[ zigbee transceiver/ or any transceiver to transmit to other transceivers to other nearby buses
    and ultimately this informatio goes to a central station.
    So
    1 ] which type of RFID reader [range and frequency]  would suit best to be kept inside buses to identify tags at stops???
    and
    2 ] which type of tranceiver [range and frequency]  would serve best to be kept inside buses to transmit and receive data???
    Can anyone tell the
    1] reception range of such readers and
    2] their respective cost and
    3] where can i get them?

    I am just stuck with one problem , I want to have elements which can avoid duplicate and also maintain order. I am not able to find the solution...Avoid duplicates => you want a set (mathematical concept), represented in the JDK standard API as interface <TT>java.util.Set</TT> (http://download.oracle.com/javase/6/docs/api/java/util/Set.html)
    "maintain order" => you probably merely want a <TT>SortedSet</TT> (http://download.oracle.com/javase/6/docs/api/java/util/SortedSet.html)
    Then browse the Javadoc to find one of the multiple classes that implement those interfaces.
    J.

  • Which collection to use in this case for best performance....

    i have two text files having 10,0000(aprox)
    phone numbers , i wish to compare both the files
    and write the matching numbers in third file..
    so which collection should i use to perform it..
    so that performance is best......
    plz send me the logic....

    > so which collection should i use to perform it..
    so that performance is best......
    Program to interfaces. That way, you can switch out implementations and test for yourself which performance is best in an actual production context. But first, write your program so that it works. Worry about refactoring for performance once your program is written and it works.
    > plz send me the logic....
    Give it a shot on your own first; we can help if you get stuck.
    ~

  • Report in which collect statement .

    report in which collect statement  is used and also its purpose.

    COLLECT
    Basic form
    COLLECT [wa INTO] itab.
    Addition
    ... SORTED BY f
    Effect
    COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab .
    If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
    If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.
    If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
    If you specify wa INTO , the entry to be processed is taken from the explicitly specified work area wa . If not, it comes from the header line of the internal table itab .
    After COLLECT , the system field SY-TABIX contains the index of the - existing or new - table entry with default key fields which match those of the entry to be processed.
    Notes
    COLLECT can create unique or compressed datasets and should be used precisely for this purpose. If uniqueness or compression are unimportant, or two values with identical default key field values could not possibly occur in your particular task, you should use APPEND instead. However, for a unique or compressed dataset which is also efficient, COLLECT is the statement to use.
    If you process a table with COLLECT , you should also use COLLECT to fill it. Only by doing this can you guarantee that
    the internal table will actually be unique or compressed, as described above and
    COLLECT will run very efficiently.
    If you use COLLECT with an explicitly specified work area, it must be compatible with the line type of the internal table.
    Example
    Compressed sales figures for each company
    DATA: BEGIN OF COMPANIES OCCURS 10,
    NAME(20),
    SALES TYPE I,
    END OF COMPANIES.
    COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 10.
    COLLECT COMPANIES.
    COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.
    COLLECT COMPANIES.
    COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 30.
    COLLECT COMPANIES.
    The table COMPANIES now has the following appearance:
    NAME SALES
    Duck 40
    Tiger 20
    Addition
    ... SORTED BY f
    Effect
    COLLECT ... SORTED BY f is obsolete and should no longer be used. Use APPEND ... SORTED BY f which has the same meaning.
    Note
    Performance
    The cost of a COLLECT in terms of performance increases with the width of the default key needed in the search for table entries and the number of numeric fields with values which have to be added up, if an entry is found in the internal table to match the default key fields.
    If no such entry is found, the cost is reduced to that required to append a new entry to the end of the table.
    A COLLECT statement used on a table which is 100 bytes wide and has a key which is 60 bytes wide and seven numeric fields is about approx. 50 msn (standardized microseconds).
    Note
    Runtime errors
    COLLECT_OVERFLOW : Overflow in integer field when calculating totals.
    COLLECT_OVERFLOW_TYPE_P : Overflow in type P field when calculating totals.

  • Which cable (original apple usb or bmw y) shall i use to connect my 4th gen iPod photo 60 gb to bmw f10 (with com box) is it going to work with the apple usb cable and how long does it take till I can access the 33gb content via the bmw display?

    Which cable (original apple usb or bmw y) shall I use to connect my 4th gen iPod photo 60 gb (old but still working ok) to bmw f10 (with com box), build december 2010 > is it going to work with the apple usb cable and if so, how long does it take till I should be able to access the 33gb content via the bmw display?
    Alternatively: How long does it take if I would have to use the bmw y cable till I can access the 33gb content via the bmw display?

    Which cable (original apple usb or bmw y) shall I use to connect my 4th gen iPod photo 60 gb (old but still working ok) to bmw f10 (with com box), build december 2010 > is it going to work with the apple usb cable and if so, how long does it take till I should be able to access the 33gb content via the bmw display?
    Alternatively: How long does it take if I would have to use the bmw y cable till I can access the 33gb content via the bmw display?

  • How shall I use my IMac and MacBookPro, with synchronized files

    Hi, how shall I use my IMac and MacBookPro, with synchronized files? I used to work at home and office with those to machines and finally always have different version of my documents. Is there any dispositive that I should use, where all my files are moving with me? os there is something to synchronized the computers using WiFi or bluetooth?

    The following has instructions: OS X Mavericks: Share your Internet connection

Maybe you are looking for

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked f

  • Update Retriever doesn't run on Windows 8

    Hi - I have started working with Microsoft's MDT 2012 update 1 to prepare for deployment of Windows 8 in our organization.    I'd like to use "Update Retriever" so I can easily import a large number of Lenovo Thinkpad drivers. However when I launch U

  • ALV Grid: Cell not available for selection

    ALV GRID. How can I make a cell(or an entire column) not available to be selected?

  • Windows Server 2012 Essentials upgrade to Windows Server 2012 Standard

    I've just upgraded a Windows Server 2012 Essentials to Standard via the Powershell command. The server restarted and is now Standard version. However I've noticed in the services that one particular service fails.  silsvc <Failed to Read Description.

  • Can't Access iPhoto Archive on External Drive in '08

    I'm scared. I've been archiving all of my family photos with iPhoto and storing them on an external drive. I recently upgraded to Leopard, and iPhoto '08 from the previous '06 version. Now I can not open / import the iPhoto Archives that are stored o