Patterns in JavaTM, Volume 3 Java Enterprise Java Enterprise Design Patterns phần 7

ChunkBufferPool đối tượng giữ một bộ sưu tập của ChunkBuffer đối tượng đang chờ tái sử dụng. Một đối tượng Multiplexer yêu cầu đối tượng ChunkBufferPool của nó cho một đối tượng ChunkBuffer khi nó cần một. Nếu đối tượng ChunkBufferPool có bất kỳ đối tượng | 292 Chapter Seven a lock on that inventory record and is trying to access the customer record that the other program already has locked. The two programs wait indefinitely to access the record that the other program has locked. You solve the problem by modifying the warranty registration program so that it locks customer records before it locks the corresponding inventory record. FORCES Multiple objects need to access a set of resources. The operations they perform on these resources require that some or all other objects be prevented from concurrently accessing the resources. Dynamically determining at runtime whether granting an object access to a resource will result in a deadlock can be a very expensive operation. Some transaction management mechanisms automatically detect deadlocks among the transactions that they manage. It will generally take them a while to detect the deadlock after it occurs. The way that most of these transaction managers handle a deadlock is to cause some or all of the transactions involved to fail. From the viewpoint of an application such failures appear to be intermittent failures of the application. If it is important that the transaction behaves in a reliable and predictable way then it is important for it to avoid such deadlocks. Objects access a set of resources that either is static or always fills a static set of roles. If resources can fill multiple roles then it may take a prohibitively long amount of time to determine in advance whether a particular pattern of accessing resources can result in a deadlock. SOLUTION If objects lock multiple shared resources then ensure that the resources are always locked in the same relative order. For example if there are four resources A B C and D then you could require all objects to lock them in that order. So one object may lock B c and D in that order. Another object may lock A and C in that order. However no object may lock C and B in that order. The same strategy applies to situations

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
46    330    2    27-06-2024
Đã 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.