Recently, I am working on a project about servers.ProgramThe design is used, and the multi-thread synchronous interaction is used. After thinking about it, I still want to use the design pattern as follows. Of course, in this development process, I also referred to thread Desgin pattern, but I feel that there are too many things in the book. I may write another log after the development, which may help me understand more. Then I will start my "thread Journey"
There are 11 design patterns in the thread design patterns. These good design methods already cover the scenarios we usually need in actual project applications. I hope you will understand the "Examples" in the following models!
Single threaded execution pattern
-- Only one person can access the bridge.
Guarded suspension Pattern
-- Wait until I am ready
Balking Pattern
Producer -- if you don't need it, forget it.
Consumer Pattern
-- Let me do it. You can use it.
Read-write lock Pattern
-- Let's take a look at it, but you can't write it when reading it.
Thread-per-message Pattern
-- This job is handed over to you.
Worker Thread pattern
-- When the job comes, it will work.
Future Pattern
-- First give you a Bill of Lading
Two-phase termination Pattern
-- Tidy up the toys. Go to bed.
Thread-specific storage pattern
-- Safe deposit box for each thread
Active Object Pattern
-- Active object for receiving asynchronous messages