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 ... |
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 ... |
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 ...
|
I'd like to be able to conditionally replace a value in a ConcurrentHashMap. That is, given:
public class PriceTick {
final String instrumentId;
...
final ... |
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 ... |
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 ... |
Is there a C# class that provides map with weak keys or/and weak values?
Or at least WeakHashMap like functionality.
|
|
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, ...
|
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:
- read from excel file, check for ...
|
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
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 ... |
If two processes in an application are updating one java.util.List object then which kind of exception will be raised?
|
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 ... |
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 ... |
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, ... |
final Multimap<Term, BooleanClause> terms = getTerms(bq);
for (Term t : terms.keySet()) {
Collection<BooleanClause> ...
|
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 ...
|
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 ... |
|
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 ... |
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(); ... |
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 ... |
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, ... |
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 ... |
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 ... |
|
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 ... |
|
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. |
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 ... |