tailieunhanh - peer-topeer Networks phần 7

11,5 Mô-đun Mô-đun này phân chia nhiệm vụ thành các nhiệm vụ và trả về các mảng nhiệm vụ cho các module gọi. Các mã nguồn được trình bày trong hình. 11,8. 11,6 Module này khác nhau từ các (Chương 9) trong những cách sau đây: r mới | 158 11. Power Server Model 3 Note that it is important to distinguish the differences between getNextNumber and getTaskNumber methods. The getNextNumber returns the number of next available sub-task but the sub-task is not assigned to the thread yet. On the other hand the getNextTask method returns the number next available sub-task and assigns it to the thread. The sub-task is assigned only when the server is ready to process it. run Method In the run method the connection is checked by the following statement if connected return The sub-task is assigned by the following statement subTask The source codes of the addClientThread2 module are presented in Fig. . Module This module divides the task into sub-tasks and returns the task array to the calling module. The source codes are presented in Fig. . This module differs from the in Chapter 9 in the following ways Two new methods are added . getTaskNumber and getNextTask. The setGoAhead method is removed as this synchronization is not required. The following are the functions of the new methods getTaskNumber return the next available task number to the calling thread. getNextTask assign and return the next available sub-task number to the calling thread. The source codes of this module are presented in Fig. . Testing Programs can be tested in a similar way to Sections and . Again I would recommend that you start with one computer even if you have several computers in front of you. Testing 159 import . import . public class divide double x long endPosition long totalTasks boolean debug public divide double x long endPosition long totalTasks boolean debug if debug divide module x endPosition totalTasks debug public void go long width endPosition totalTasks dividing job into sub-tasks for int i 0 i i i 2 if i 0 x i 1 else x i x

TỪ KHÓA LIÊN QUAN