collection « Development « Java Thread Q&A

Home
Java Thread Q&A
1.concurrency
2.Development
3.Exception
4.Notify
5.Operation
6.Socket
7.State
8.synchronize
9.Thread Safe
10.ThreadPool
Java Thread Q&A » Development » collection 

1. BlockingQueue: put() and isEmpty() do not work together?    stackoverflow.com

I would like to have a SynchronousQueue where I insert elements from one thread with put(), so the input is blocked until the element is taken in another thread. In the other ...

2. Collection Alternative - ConcurrentModificationException    stackoverflow.com

I'm iterating over a JRE Collection which enforces the fail-fast iterator concept. Problem is I need to remove an object's logical partner if the object meets a condition. Thus preventing the ...

3. "Exception in thread "main" java.lang.NullPointerException when adding to a HashMapList    stackoverflow.com

HashMapList keeps its elements inside a HashMap) and when I call add method this error message will be shown in the concole "Exception in thread "main" java.lang.NullPointerException

public class HashMapList<K, V extends ...

4. ConcurrentHashMap Conditional Replace    stackoverflow.com

I'd like to be able to conditionally replace a value in a ConcurrentHashMap. That is, given:

public class PriceTick {
   final String instrumentId;
   ...
   final ...

5. CopyOnWriteArrayList throwing CurrentModificationException    stackoverflow.com

I'm occasionally getting a ConcurrentModificationException when I iterate over a list. A Google search informs me that it's probably because I'm altering that list in another thread while iterating over ...

6. How do you interate over a Collection and modify its items without ConcurrentModificationException?    stackoverflow.com

I need to do something like this...

Collection<T> myCollection; ///assume it is initialized and filled


for(Iterator<?> index = myCollection.iterator(); index.hasNext();)
{
    Object item = index.next();
    myCollection.remove(item);
}
Obviously this throws ...

7. Is there an equivalent for Java WeakHashMap class in C#?    stackoverflow.com

Is there a C# class that provides map with weak keys or/and weak values? Or at least WeakHashMap like functionality.

8. Multi-thread object?object cache map in Java?    stackoverflow.com

I want a collection in Java which:

  • maps arbitrary Objects to Objects (not String or otherwise restricted keys only)
  • will be used as a cache; if the key is not in the cache, ...

9. Multiple threads modifying a collection in Java?    stackoverflow.com

The project I am working on requires a whole bunch of queries towards a database. In principle there are two types of queries I am using:

  1. read from excel file, check for ...

10. What's the fastest Java collection for single threaded Contains(Point(x,y)) functionality?    stackoverflow.com

In my application I need to check a collection of 2D coordinates (x,y) to see if a given coordinate is in the collection, it needs to be as fast as ...

11. Storing each thread's data when using Semaphore    stackoverflow.com

My task was to deal with problem of 5 eating thinkers. Each of them can eat only 10 times. Solution should base on Semaphore. I almost solved the task and output ...

12. What collection supports multiple simultaneous insertions?    stackoverflow.com

We are developing a Java application with several worker threads. These threads will have to deliver a lot of computation results to our UI thread. The order in which the results ...

13. java statistics collection for performance evaluation    stackoverflow.com

What is the most efficient way to collect and report performance statistic analysis from an application?
If I have an application that uses a series of network apis, and I want to ...

14. Best way to read/learn how to produce fast Java Collections?    stackoverflow.com

Are there any good books/websites for learning about the low-level details on Java collections/structures? I'd like to find out the fastest way to implement a Last In, First Out (LIFO) structur similar ...

15. What is the right Java collection to use in this case?    stackoverflow.com

I need to hold a large number of elements (500k or so) in a list or a set I need to do high performance traversal, addition and removal. This will be ...

16. If two processes updating a Collection at a time then which exception will be raised?    stackoverflow.com

If two processes in an application are updating one java.util.List object then which kind of exception will be raised?

17. Returning Java Arrays vs Collections    stackoverflow.com

I'm trying to think through some design in regards to memory allocation and multithreading in a java app and this is what I'm wondering: I have a class that has a ...

18. modify a list map getting ConcurrentModificationException    stackoverflow.com

Hi I am creating two lists to hold good and bad data values. I pass these lists to a method where I add a new key value to the goodMap, check some ...

19. concurrentModificationException    stackoverflow.com

With the snippet below I am, attempting to process a spreadsheet, with the twist of needing to exclude ad hoc columns. I know the crude way I am doing it, ...

20. Why does it.next() throw java.util.ConcurrentModificationException?    stackoverflow.com

final Multimap<Term, BooleanClause> terms = getTerms(bq);
        for (Term t : terms.keySet()) {
            Collection<BooleanClause> ...

21. When do lists, collections etc throw a java.util.ConcurrentModificationException in Java?    stackoverflow.com

The following code uses a simple list and displays elements contained in the list through a foreach loop and again through a while loop.

final public class Main
{
    public ...

22. Looking through collections    coderanch.com

This from the (Java 2) javadoc entry for java.util.Vector: 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. Thus, in the face of concurrent modification, the Iterator ...

23. threads and collections    coderanch.com

24. Problems with Multithreading and Collections    coderanch.com

Hi, all! On several occasions I tried to access a java.util.LinkedList ll using two threads to write data to the beginning (using addFirst()) while trying to extract data from the end (using removeLast()) thus creating something like a buffer for sequential data access. Alas! In a better world it would all have worked out the way I planned it. In reality ...

25. Using two iterators on same collection    coderanch.com

Hi, Just tried using two iterators on the same collection(Vector in this case),but getting the ConcurrentModification Exception sometimes. The error occurs randomly with no predicted behaviour. Not able to pin point the source of error Here is the snippet, line of error is indicated in comment Would be grateful for any explanation..Thnx private Vector mergeVisualEvents(Vector visualEvents) { Log.debug("inside mergeVisualEvents"); for(Iterator it=visualEvents.iterator(); ...

26. access Object in collection of Threads    coderanch.com

Maybe I didn't explain this correctly. We start up multiple threads when our web application starts up to process some things. These threads periodically wake up check for work and process, they won't die unless we tell them to stop. So the thread hasn't died or been garbage collected. The collection of threads is a static variable. We want to iterate ...

27. Multiple threads reading from a Collection    coderanch.com

Hi, Following is the code I have written. Are there any chances of ConcurrentAccessException to arise if multiple threads are calling isExcluded method? There is no synchronization stuff in the code below, once this data is loaded it will not be changed. - Is the object locked while reading as well? - I can also pack these things in a ConcurrentHashMap, ...

28. Create a new thread for each entity in a collection.    coderanch.com

I need some advice and suggestions from some Thread experts about the possibility of my algorithm for concurrent Threads. A newbie in concurrent Java programming. The algorithm is outlined as follows: 1. A Java Collection is defined containing various of entities. 2. Iterate through all the entities in this Collection with the current thread. And create a new thread for each ...

29. some questions related to thread,casting,collection framework and more...    coderanch.com

hello all.... I am searching for a proper solution,can anyone help me? :roll: > describe the hierarchy structure of the interfaces which are included in Collection framework. > difference between pass by value and pass by reference in JAVA? > how do we implement synchronization concept in java? > difference between anonymous class and local class in static context and non-static ...

30. Collections.synchronizedMap?    coderanch.com

31. Threading and collections problem.Pl help    coderanch.com

Iam stuck in this problem and have spent almost 5-6 hours in it. In the project i am implementing TCP over UDP. When stream.activate() is called the following new Thread is implemented socket.receive(packet); list.add(packet); //List is LinkedBlockingQueue. THe functions is basically whenever it the server receives any packet, it stores in the lsit and later other Thread removes from it Now ...

33. Thread FAQ:findind removed collection elements    forums.oracle.com

Well they're not in the collection any more, are they? so the thread that removed them will have to remember them somewhere, or else the other thread will need a copy of the original collection. It's not a Thread FAQ question. Any two classes that used the collection would have the same issue.

34. Query on using Collection object in Multithreading    forums.oracle.com

All, I have a query on multithreading, I have a collection object-eg. HashMap which needs to be shared among threads, I my have 3 options 1st option is to synchronize the method which does some manipulation on the collection object, 2nd option is to hold a lock on that object like synchronized(object){ //do some work } 3rd option - to make ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.