Freeze example from manual loops (Java)

in Help Center
Maybe related to my recent request-for-help on the C++ example in section 40.3.7, here's a different problem with the Java example in section 40.3.8:
After "slice2freezej --dict StringIntMap,string,int" and keying the code (Client.java), I compile the code sucessfully with "javac Client.java". When I invoke the class ("java Client"), the program does not terminate. Debugging shows that the "while (p.hasNext()) {}" loop does not finish as expected. When I insert "System.out.println(e);" as a fourth line in the block, the output is "a=1 ... z=26" and then the program "just sits there".
Does it wait for a "next" element in the Freeze map?
Andreas
After "slice2freezej --dict StringIntMap,string,int" and keying the code (Client.java), I compile the code sucessfully with "javac Client.java". When I invoke the class ("java Client"), the program does not terminate. Debugging shows that the "while (p.hasNext()) {}" loop does not finish as expected. When I insert "System.out.println(e);" as a fourth line in the block, the output is "a=1 ... z=26" and then the program "just sits there".
Does it wait for a "next" element in the Freeze map?

Andreas
0
Comments
Andreas
As described in the Ice manual 40.3.3 http://www.zeroc.com/doc/Ice-3.2.1/manual/Freeze.41.3.html
There is, however, one situation where an explicit iterator close is needed to avoid self-deadlock:
• you do not use transactions, and
• you have an opened iterator that was used to update a map (it holds a write lock), and
• in the same thread, you read that map.
This is exactly the case in your demo application. Therefore you must explicitly close the map iterators. The following fixes your demo:
Andreas