ch3.sharedVariable
Class Controller

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by ch3.sharedVariable.error.Controller
              extended by ch3.sharedVariable.Controller
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class Controller
extends Controller

Extends the shared variable example, but synchronizes the access to the variable so that there is not sharing error.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ch3.sharedVariable.error.Controller
accessCount
 
Constructor Summary
Controller()
           
 
Method Summary
 void incrementSharedVariable()
          Helper method that simulates loading a variable into memory, incrementing it and storing it back into memory.
 
Methods inherited from class ch3.sharedVariable.error.Controller
doGet, jspLocation
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Controller

public Controller()
Method Detail

incrementSharedVariable

public void incrementSharedVariable()
Helper method that simulates loading a variable into memory, incrementing it and storing it back into memory. It uses synchronization to prevent simultaneous access from different threads.

Overrides:
incrementSharedVariable in class Controller