TAILIEUCHUNG - Introduction to Programming Using Java Version 6.0 phần 9

Các công đoàn của hai tập hợp A và B là một tập hợp có chứa tất cả các yếu tố có trong A cùng với tất cả các yếu tố có trong B. Giao điểm của A và B là tập hợp chứa các yếu tố có trong cả A và B. sự khác biệt của A và B là tập hợp chứa tất cả các yếu tố của A trừ những yếu tố cũng được B. | CHAPTER 12. THREADS AND MULTIPROCESSING 595 definition of an instance method is pretty much equivalent to putting the body of the method in a synchronized statement of the form synchronized this . . It is also possible to have synchronized static methods a synchronized static method is synchronized on the special class object that represents the class containing the static method. The real rule of synchronization in Java is this Two threads cannot be synchronized on the same object at the same time that is they cannot simultaneously be executing code segments that are synchronized on that object. If one thread is synchronized on an object and a second thread tries to synchronize on the same object the second thread is forced to wait until the first thread has finished with the object. This is implemented using something called a synchronization lock. Every object has a synchronization lock and that lock can be held by only one thread at a time. To enter a synchronized statement or synchronized method a thread must obtain the associated object s lock. If the lock is available then the thread obtains the lock and immediately begins executing the synchronized code. It releases the lock after it finishes executing the synchronized code. If Thread A tries to obtain a lock that is already held by Thread B then Thread A has to wait until Thread B releases the lock. In fact Thread A will go to sleep and will not be awoken until the lock becomes available. As a simple example of shared resources we return to the prime-counting problem. In this case instead of having every thread perform exactly the same task we ll so some real parallel processing. The program will count the prime numbers in a given range of integers and it will do so by dividing the work up among several threads. Each thread will be assigned a part of the full range of integers and it will count the primes in its assigned part. At the end of its computation the thread has to add its count to the overall .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.