But there is more to synchronization than mutual exclusion. Synchronization ensures that memory writes by a thread before or during a synchronized block are made visible in a predictable manner to other threads which synchronize on the same monitor. After we exit a synchronized block, we release the monitor, which has the effect of flushing the cache to main memory, so that writes made by this thread can be visible to other threads. Before we can enter a synchronized block, we acquire the monitor, which has the effect of invalidating the local processor cache so that variables will be reloaded from main memory. We will then be able to see all of the writes made visible by the previous release.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try (Connection con = ds.getConnection()) {
// применяете
}
}
-Dorg.apache.catalina.startup.EXIT_ON_INIT_FAILURE=true
System.exit(1)
<Server port="8005" shutdown="someLongAndSecretString">
Socket socket = new Socket("localhost", 8005);
if (socket.isConnected()) {
PrintWriter pw = new PrintWriter(socket.getOutputStream(), true);
pw.println("someLongAndSecretString");
pw.close();
socket.close();
}
@RequestMapping(value = "/pet/update", method = RequestMethod.PUT)
@ResponseBody
public Pet updatePet(@Valid @ModelAttribute Pet pet) {
...
}
{% block scripts %}
{{ block.super }}
<script type="text/javascript" src="{% static 'js/footer.js' %}"></script>
{% endblock %}
{{ block.super }}
подставится содержимое родительского блока.