core java volume 1 fundamental 8th edition 2008 phần 10

Bắt đầu lập trình đôi khi sử dụng quá mức ưu tiên chủ đề. Có vài lý do bao giờ hết để tinh chỉnh priorites. Bạn nên chắc chắn không bao giờ cấu trúc chương trình của bạn để hoạt động đúng của họ phụ thuộc vào mức độ ưu tiên. | Chapter 14. Multithreading Simpo PDF Merge and Split Unregistered Version - http 734 Chapter 14 Multithreading Beginning programmers sometimes overuse thread priorities. There are few reasons ever to tweak priorites. You should certainly never structure your programs so that their correct functioning depends on priority levels. CAUTION If you do use priorities you should be aware of a common beginner s error. If you have several threads with a high priority that don t become inactive the lower-priority threads may never execute. Whenever the scheduler decides to run a new thread it will choose among the highest-priority threads first even though that may starve the lower-priority threads completely. API I void setPriority int newPriority sets the priority of this thread. The priority must be and Use for normal priority. static int MIN_PRIORITY is the minimum priority that a Thread can have. The minimum priority value is 1. static int NORM_PRIORITY is the default priority of a Thread. The default priority is 5. static int MAX_PRIORITY is the maximum priority that a Thread can have. The maximum priority value is 10. static void yield causes the currently executing thread to yield. If there are other runnable threads with a priority at least as high as the priority of this thread they will be scheduled next. Note that this is a static method. Daemon Threads You can turn a thread into a daemon thread by calling true There is nothing demonic about such a thread. A daemon is simply a thread that has no other role in life than to serve others. Examples are timer threads that send regular timer ticks to other threads or threads that clean up stale cache entries. When only daemon threads remain the virtual machine exits. There is no point in keeping the program running if all remaining threads are daemons. Daemon threads are sometimes mistakenly used by .

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
Đã 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.