Thread Design Mode

Source: Internet
Author: User

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

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.