High concurrency, thread pool

1. High concurrent content 

Zookeeper distributed service framework is a sub-project of Apache Hadoop. It is mainly used to solve some data management problems often encountered in distributed applications.

Such as: unified naming service, state synchronization service, cluster management, management of distributed application configuration items, etc.

This article will introduce the meaning of each configuration item in Zookeeper installation and configuration file in detail from the user's point of view.

And analyze typical application scenarios of Zookeeper (configuration file management, cluster management, synchronization locks, leader election, queue management, etc.)

 

DUBBO is a distributed service framework dedicated to providing high-performance and transparent RPC remote service invocation solutions.

It is the core framework of Alibaba's SOA service-based governance solution, providing 3,000,000,000+ visits per day for 2,000+ services,

And is widely used in the member sites of Alibaba Group

 

 

2. The type, content and use of the thread pool

Several thread pools provided by JDK

 

newFixedThreadPool

Creates a thread pool with the specified number of worker threads. Whenever a task is submitted, a worker thread is created. If the number of worker threads reaches the initial maximum number of the thread pool, the submitted task is stored in the pool queue.

 

newCachedThreadPool

Create a cacheable thread pool. The characteristics of this type of thread pool are: 

1). There is almost no limit to the number of worker threads created (in fact, there is a limit, the number is Interger. MAX_VALUE), so that threads can be flexibly added to the thread pool. 

2). If the task is not submitted to the thread pool for a long time, that is, if the worker thread is idle for the specified time (1 minute by default), the worker thread will be automatically terminated.

After termination, if you submit a new task, the thread pool recreates a worker thread.

 

newSingleThreadExecutor

Create a single-threaded Executor, that is, only create a single worker thread to execute tasks, if this thread ends abnormally, another one will replace it,

Guaranteed sequential execution (I think this is its specialty). The biggest feature of a single worker thread is that it guarantees that tasks are executed sequentially, and that no more than one thread is active at any given time.

 

newScheduleThreadPool

Create a fixed-length thread pool, and support timed and periodic task execution, similar to Timer. (The principle of this thread pool has not been fully understood yet)

 

Summarize:

FixedThreadPool

It is a typical and excellent thread pool. It has the advantages of thread pool improving program efficiency and saving the overhead when creating threads. However, when the thread pool is idle,

That is, when there are no runnable tasks in the thread pool, it will not release the worker threads and will occupy certain system resources.

 

CachedThreadPool

The feature is that when the thread pool is idle, that is, when there are no runnable tasks in the thread pool, it will release the worker thread, thereby releasing the resources occupied by the worker thread.

However, when a new task appears, a new worker thread needs to be created, and a certain system overhead is required. And, when using CachedThreadPool,

Be sure to pay attention to controlling the number of tasks, otherwise, due to a large number of threads running at the same time, the system will be paralyzed.

 

 

3.spring的AOP

4. The relationship of list set, and its extension. The difference between arraylist and linkedList

5. The relationship between abstract classes and interfaces

6. Two ways of multithreading

7.mq redis related usage

 

8. Batch submission label of mybatis

<insert id="addTrainRecordBatch" useGeneratedKeys="true" parameterType="java.util.List">  

    <selectKey resultType="long" keyProperty="id" order="AFTER">  

        SELECT  

        LAST_INSERT_ID()  

    </selectKey>  

    insert into t_train_record (add_time,emp_id,activity_id,flag)   

    values  

    <foreach collection="list" item="item" index="index" separator="," >  

        (#{item.addTime},#{item.empId},#{item.activityId},#{item.flag})  

    </foreach>  

</insert>

 

9. The difference between statement preparestatment

10.Linux query the first N lines of the log file

 

11. Aggregate functions of the database

insert into test values(1,'u1',1.2);

insert into test values(2,'u1',1.3);

insert into test values(3,'u2',2.3);

insert into test values(4,'u2',2.2);

insert into test values(5,'u3',3.5);

insert into test values(6,'u4',4.3);

insert into test values(7,'u4',4.2);

--decialal 5,4 means the total is 5 digits, 4 of which are decimals

-- order by user_id subquery should not have order by 

select sum(user_order_num),count(*),avg(tt) from (

 

select user_id, count(* ) as user_order_num,sum(order_amt) as order_amt, avg(order_amt) as tt from test group by user_id)ppp

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326828456&siteId=291194637