TAILIEUCHUNG - Parallel Programming: for Multicore and Cluster Systems- P33

Parallel Programming: for Multicore and Cluster Systems- P33: Innovations in hardware architecture, like hyper-threading or multicore processors, mean that parallel computing resources are available for inexpensive desktop computers. In only a few years, many standard software products will be based on concepts of parallel programming implemented on such hardware, and the range of applications will be much broader than that of scientific computing, up to now the main application area for parallel computing | 312 6 Thread Programming The method yield is a directive to the Java Virtual Machine JVM to assign another thread with the same priority to the processor. If such a thread exists then the scheduler of the JVM can bring this thread to execution. The use of yield is useful for JVM implementations without a time-sliced scheduling if threads perform long-running computations which do not block. The method enumerated yields a list of all active threads of the program. The return value specifies the number of Thread objects collected in the parameter array tharray. The method activeCount returns the number of active threads in the program. The method can be used to determine the required size of the parameter array before calling enumerated . Example Figure gives an example of a class for performing a matrix multiplication with multiple threads. The input matrices are read into ini and in2 by the main thread using the static method ReadMatrix . The thread creation is performed by the constructor of the MatMult class such that each thread computes one row of the result matrix. The corresponding computations are specified in the run method. All threads access the same matrices ini in2 and out that have been allocated by the main thread. No synchronization is required since each thread writes to a separate area of the result matrix out. Synchronization of Java Threads The threads of a Java program access a shared address space. Suitable synchronization mechanisms have to be applied to avoid race conditions when a variable is accessed by several threads concurrently. Java provides synchronized blocks and methods to guarantee mutual exclusion for threads accessing shared data. A synchronized block or method avoids a concurrent execution of the block or method by two or more threads. A data structure can be protected by putting all accesses to it into synchronized blocks or methods thus ensuring mutual exclusion. A synchronized increment operation of a counter can .

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.