Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Sức khỏe - Y tế
Văn bản luật
Nông Lâm Ngư
Kỹ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Giới thiệu
Đăng ký
Đăng nhập
Tìm
Danh mục
Kinh doanh - Marketing
Kinh tế quản lý
Biểu mẫu - Văn bản
Tài chính - Ngân hàng
Công nghệ thông tin
Tiếng anh ngoại ngữ
Kĩ thuật công nghệ
Khoa học tự nhiên
Khoa học xã hội
Văn hóa nghệ thuật
Y tế sức khỏe
Văn bản luật
Nông lâm ngư
Kĩ năng mềm
Luận văn - Báo cáo
Giải trí - Thư giãn
Tài liệu phổ thông
Văn mẫu
Thông tin
Điều khoản sử dụng
Quy định bảo mật
Quy chế hoạt động
Chính sách bản quyền
Giới thiệu
Đăng ký
Đăng nhập
0
Trang chủ
Công Nghệ Thông Tin
Kỹ thuật lập trình
Thinking in Java 4th Edition phần 9
Đang chuẩn bị liên kết để tải về tài liệu:
Thinking in Java 4th Edition phần 9
Ngọc Vy
58
108
pdf
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Vì vậy, bạn phải cẩn thận phân tích thí nghiệm của bạn và để hiểu những hạn chế của họ. Tùy thuộc vào hành vi mà bạn mong muốn, Để chạy chương trình, bạn gõ một dòng lệnh của một trong hai: Lựa chọn giữa Bộ | Simpo PDF Merge and Split Unregistered Version - http www.simpopdf.com Exercise 15 1 Create a class with three methods containing critical sections that all synchronize on the same object. Create multiple tasks to demonstrate that only one of these methods can run at a time. Now modify the methods so that each one synchronizes on a different object and show that all three methods can be running at once. Exercise 16 1 Modify Exercise 15 to use explicit Lock objects. Thread local storage A second way to prevent tasks from colliding over shared resources is to eliminate the sharing of variables. Thread local storage is a mechanism that automatically creates different storage for the same variable for each different thread that uses an object. Thus if you have five threads using an object with a variable x thread local storage generates five different pieces of storage for x. Basically they allow you to associate state with a thread. The creation and management of thread local storage is taken care of by the java.lang.ThreadLocal class as seen here concurrency ThreadLocalVariableHolder.java Automatically giving each thread its own storage. import java.util.concurrent. import java.util. class Accessor implements Runnable private final int id public Accessor int idn id idn public void run while Thread.currentThread .isInterrupted ThreadLocalVariableHolder.increment System.out.println this Thread.yield public String toString return id ThreadLocalVariableHolder.get public class ThreadLocalVariableHolder private static ThreadLocal Integer value new ThreadLocal Integer private Random rand new Random 47 protected synchronized Integer initialValue return rand.nextInt 10000 . public static void increment value.set value.get 1 public static int get return value.get public static void main String args throws Exception ExecutorService exec Executors.newCachedThreadPool for int i 0 i 5 i exec.execute new Accessor i TimeUnit.SECONDS.sleep 3 Run for a while exec.shutdownNow All .
TÀI LIỆU LIÊN QUAN
Thinking in Java_ Bruce Eckel
Thinking in Java
Lecture Introduction to Java programming - Chapter 10: Thinking in objects
Java Collections
Thinking in Java 4th Edition phần 3
Thinking in Java 4th Edition phần 4
Thinking in Java 4th Edition phần 5
Thinking in Java 4th Edition phần 6
Thinking in Java 4th Edition phần 7
Thinking in Java 4th Edition phần 8
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.