Searching for the magic ParallelHashMap class
More succinctly, can you use multiple threads to speed up HashMap lookups? Are there any implementations out there that do this already?
In my project, we need ... |
I write following code but when this run it generate concurrentmodificationexception
if( attendancePolicy.getType().equals( AttendanceConstants.EMPLOYEE_ATTENDANCE_POLICY ) ) {
synchronized( attendancePolicy.getListEmployee() ) {
for( ...
|
I'm looking for a good hash map implementation. Specifically, one that's good for creating a large number of maps, most of them small. So memory is an issue. It should be ... |
I need a thread-safe Map with a time limited expiry policy. I tried looking for an existing library, but could not find one. Jboss cache is going to be a heavy ... |
I know that Hashtable is synchronized so it is safe to be used in multithread app and HashMap is not.
I am wondering if there is any ... |
Hi I am running a thread service, the job of this thread is to check the age of a list items in a HashMap. When an item is older than ... |
I am facing scalability issue while reading data from hashmap. My machine has 32 core with 2 hyper thread per core (so total 64 cpus) and 64 GB RAM.
When ... |
|
I have a caching structure in a servlet currently implemented with a Hashtable and I'm wondering if I can convert it to a HashMap for efficiency. The hash contains string arrays and corresponds to data in my database. I preload the hash in the servlet init() method and I have a background thread that updates the cache every six hours -- ... |
Hi all, My application will be run under a mutilthreaded environ. I have a job queue represented as a Hashtable. Each key in hashtable contains a vector as its corresponding value. This is done to bring about one-2-many relations between key & values in the hashtable. For eg: class test { Map jobQueue; public test() { this.jobQueue = new Hashtable(); this.jobQueue.put(new ... |
I'm sure this has been posted before on this list. I have an application where there is a common data structure being shared by multiple threads (say A), which are updating this data structure. Another single thread (B), which is iterating over the entries and taking an action on each entry. (Not updating the data structure). For this application, After going ... |
public class MyData { // volatile so that threads are forced to r & w the memory copy private volatile Map data; public void update() { Map newData = new HashMap(data); // update newData with the new data // ... // now make the new data visible data = Collections.unmodifiableMap(newData); } public Map getData() { return data; } } |
You shouldn't be trying to figure out the limits of the damage, either it is thread safe or it isn't. Using a collection that is not thread safe with multiple threads because you are will to accept certain data inconsistencies is not a good idea. However, in this case, the HashMap class does document the extent that you are allowed to ... |
|
This is what the docs say about HashMaps reg synchronization If multiple threads access this map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with a key that an instance already contains is ... |
Your problem doesn't sound like a Hashtable vs HashMap issue. As a previous poster said if you are having performance problems it surely doesn't have to do with that choice. you need to measure your codes performance and find out where the real bottleneck is. Random Micro-tunings such as this are almost always a waste of time. Your issue is probably ... |
|
import java.io.*; import java.util.*; public class DeSerThread implements Runnable { Map myMap; public Map getMyMap() { return myMap; } public void run(){ try { FileInputStream fi = new FileInputStream("cde.tmp"); ObjectInputStream si = new ObjectInputStream(fi); myMap = (HashMap) si.readObject(); si.close(); System.out.println("done with run"); } catch (Exception e) { e.printStackTrace(); } } } and import java.io.*; import java.util.*; public class SerThread implements Runnable ... |
Hi, we are using dom4j for creating the XML request and making a http post call to external client, but since few weeks we are experiencing hung threads issue and when i got the thread dump, this is what i see and lot of them . Is this a known issue ? or am i missing something ? Any help whould ... |
(PLEASE answer in "little java words" for I am learning. |
If I were to create my own locking methods for a hashmap and queue woutl that be a safer way to handle multiple threads reading and writing to the hashmap in my main thread. example below. then I can use my calls to lock in all my hashmap reads and writes. also, I have a thread that will be walking the ... |
We also have a hashmap that supposed to store each writer thread so that whenever a message is sent to the server it gets outputted to each client by its writer thread(Like a chat room). The problem is I'm not to sure how to take the message given to the sever and output it through the writer threads. Heres the hashmap ... |
Think of a Map as a set of (key, value) entries. Removing a key from a map's key set removes the entire entry from the map's set of entries. The alternative doesn't make any sense, does it: you remove the key from the map, but the value still somehow floats around inside the map? |
Hi I have a hashmap containing a series of objects. I need to perform calculations on these objects and write the updaste versions back into the hash map and time how long the calculations taker. Does anyone know how I can do this using threading? I would like the thread to become active every few seconds, calculate and write back to ... |
This code is not thread-safe. I'm guessing this why you think notifyAll is not working. I'll break it down for you: - You have one shared HashMap - You have 5 threads - You have 5 instances of ModiMap, one for each thread - Each ModiMap only synchronizes on itself (synchronized member method) - While Thread A (and ModiMap-A) is modifying ... |
It simply finds out the last modified time of each folder(based on last modified time of any of the files within its subfolders, directory depth may vary tremendously, in some cases it exceeded Windows MAXPATH of 260 chars) and size of specific subfolders within the folder. Well do you know any technique to uniformly distribute threads across the disks in server? ... |