JDK 7

JDK 7
Some nifty features being added…

Support for strings in a switch/case, a true filesystem API for things like directory search, improved GC, breakdown of the platform into modules to reduce memory footprint of the runtime.

Demo

Advertisements

Livelock

Livelock
A thread often acts in response to the action of another thread. If the other thread’s action is also a response to the action of another thread, then livelock may result. As with deadlock, livelocked threads are unable to make further progress. However, the threads are not blocked — they are simply too busy responding to each other to resume work. This is comparable to two people attempting to pass each other in a corridor: Alphonse moves to his left to let Gaston pass, while Gaston moves to his right to let Alphonse pass. Seeing that they are still blocking each other, Alphone moves to his right, while Gaston moves to his left. They’re still blocking each other, so…

more info

Persisting state in Servlets

Only a single instance of the servlet is created, and each request simply results in a new thread calling the servlet’s service method (which calls doGet or doPost). So, shared data simply has to be placed in a regular instance variable (field) of the servlet. Thus, the servlet can access the appropriate ongoing calculation when the browser reloads the page and can keep a list of the N most recently requested results, returning them immediately if a new request specifies
the same parameters as a recent one. Of course, the normal rules that require authors to synchronize multithreaded access to shared data still apply to servlets.

Servlets can also store persistent data in the Servlet-Context object that is available through the getServletContext method. ServletContext has setAttribute and getAttribute methods that let you store arbitrary data associated with specified keys.

The difference between storing data in instance variables and storing it in the Servlet- Context is that the ServletContext is shared by all servlets in the servlet engine.