tailieunhanh - Core Servlets and JavaServer Pages phần 2

Bất cứ khi nào lên lịch và quyết định để chạy một chủ đề mới, nó sẽ chọn trong số các chủ đề ưu tiên cao nhất đầu tiên, mặc dù có thể chết đói các chủ đề lowerpriority hoàn toàn. Bất cứ khi nào lên lịch và quyết định để chạy một chủ đề mới, nó sẽ chọn trong số các chủ đề ưu tiên cao nhất đầu tiên, mặc dù có thể chết đói các chủ đề lowerpriority hoàn toàn. | Prentice Hall and Sun Microsystems. Personal use only do not redistribute. Chapter 2 First Servlets automatically uses the status line and header settings of doGet to answer HEAD requests. The SingleThreadModel Interface Normally the system makes a single instance of your servlet and then creates a new thread for each user request with multiple simultaneous threads running if a new request comes in while a previous request is still executing. This means that your doGet and doPost methods must be careful to synchronize access to fields and other shared data since multiple threads may be trying to access the data simultaneously. See Section Persistent Servlet State and Auto-Reloading Pages for more discussion of this. If you want to prevent this multithreaded access you can have your servlet implement the SingleThreadModel interface as below. public class YourServlet extends HttpServlet implements SingleThreadModel . If you implement this interface the system guarantees that there is never more than one request thread accessing a single instance of your servlet. It does so either by queuing up all the requests and passing them one at a time to a single servlet instance or by creating a pool of multiple instances each of which handles one request at a time. This means that you don t have to worry about simultaneous access to regular fields instance variables of the servlet. You do however still have to synchronize access to class variables static fields or shared data stored outside the servlet. Synchronous access to your servlets can significantly hurt performance latency if your servlet is accessed extremely frequently. So think twice before using the SingleThreadModel approach. The destroy Method The server may decide to remove a previously loaded servlet instance perhaps because it is explicitly asked to do so by the server administrator or perhaps because the servlet is idle for a long time. Before it does however it calls the servlet s destroy method. This

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.