I have a question What happend when I declare a variable inside a method, for example. void myMethod() { Ship myShip = new Ship(); } Where is allocated myShip reference, in stack or in the heap ? I think in stack but I’m confused because I was reading in J2ME Game Programming book “Java classes are instantiated onto the Java
Tag: concurrency
What’s the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)?
I have a Map which is to be modified by several threads concurrently. There seem to be three different synchronized Map implementations in the Java API: Hashtable Collections.synchronizedMap(Map) ConcurrentHashMap From what I understand, Hashtable is an old implementation (extending the obsolete Dictionary class), which has been adapted later to fit the Map interface. While it is synchronized, it seems to
Java ReentrantReadWriteLocks – how to safely acquire write lock when in a read lock?
I am using in my code at the moment a ReentrantReadWriteLock to synchronize access over a tree-like structure. This structure is large, and read by many threads at once with occasional modifications to small parts of it – so it seems to fit the read-write idiom well. I understand that with this particular class, one cannot elevate a read lock