4 Star 19 Fork 8

caodianming/Java-Concurrency-Progamming-Tutorial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

0 Java 高并发理论 基础知识点全覆盖

无论跳槽面试 / 开发,技能都将高人一等

1 多线程并发与线程安全,让程序更可靠

大量代码实例来讲解,深度掌握高并发编程

2 高并发处理思路与手段,让跳槽面试从容不迫

2.1 接轨企业需求的并发技能

从真实应用场景出发,从0解构线程与并发

2.2 并发面试综合案例

并发面试必问考点,理清思路总结要点

2.3 设计巧妙易于理解

巧妙实例便于理解

2.4 深入理解底层原理 解决企业级并发业务问题 翻越并发技术的大山

线程的核心

工作/面试的利器

  • 线程N种实现方式 网络众口不一,真伪难辨,本教程直击本质

  • 线程启动你真的会么? 启动线程,从错误到正确,带你从错误中总结真理

  • 线程停止、中断的最佳实践 把我线程停止原则

  • 图解线程生命周期 面试 show 出此图,优秀候选人非你莫属

  • 趣解Thread和Object类中线程相关方法 wait、notify、join、yield…各有千秋

  • 一网打尽线程属性线程属性 三大经典面试问题,你晓得么?

  • 线程异常处理 无处不在的异常,只需一招自定义异常

  • 线程安全与程序性能,取舍之道 线程安全导致性能降低,看似无解,实则只是学艺不精

3 精讲Java面试中的高频并发问题

为什么wait必须在同步代码块中使用?

线程是如何在6种状态之间切换的?

哪些场景需要额外注意线程安全问题?

讲一讲什么是Java内存模型?

happens-before、volatile和可见性的关系?

实际开发中如何避免死锁?

4 领悟Java大佬的学习方法与体系思想

如何从宏观和微观两个方面来提高技术?

提高技术的途径有哪些?

如何了解技术领域的前沿动态?

工作中业务缠身,如何在业务开发中得到更多成长?

如何分析native的c/cpp代码,如何使用openJDK?

“自顶向下”的学习方法以及好处?

5 环境参数

基本工具

  • Maven 3.3.9+

  • JDK 8+

  • Tomcat 8+

  • MySQL 8.0.16+

  • Redis 5+

IDE

Intellij IDEA 2019.2+

测试工具

Postman

JMeter

框架

SpringBoot

Mybatis

组件

Kafka

RabbitMQ

elastic-job...

6 知识点概要

线程安全性

线程安全性,主要从原子性、可见性、有序性三个方面

原子性部分, atomic包下相关类、CAS原理、Unsafe类、synchronized关键字等的使用及注意事项 可见性部分,主要介绍的是volatile关键字的规则和使用,及synchronized关键字的可见性 有序性部分,则重点讲解了happens-before原则

安全发布对象

安全发布对象的一些核心方法,主要通过单例类的多种实现方式,让大家在实现过程中去体会这些方法的具体含义 这也是对线程安全性的巩固,也是把线程安全性涉及的一些关键字和类再一次放到实际场景中使用,加深大家对他们的印象和认识

线程安全策略

线程安全策略,包括定义不可变对象、线程封闭、同步容器、并发容器等,引出并发里的关键知识J.U.C。

同时还额外介绍了开发中常见的一些线程不安全类和写法,并给出他们各自对应的替代方案。这一章涉及的内容在日常开发和面试中都会涉及很多。...

J.U.C之AQS讲解

AQS是J.U.C的重要组件,也是面试的重要考点。

AQS模型设计及相关同步组件的原理和使用,都非常实用,具体包括:CountDownLatch、Semaphore、CyclicBarrier、ReentrantLock与锁、Condition等。

这些组件需要大家能熟练明白他们的用途及差异,不但会使用,而且还要明确知道不同方法调用后的不同效果。...

J.U.C组件拓展

J.U.C相关组件,主要包括FutureTask、Fork/Join框架、BlockingQueue,其中FutureTask讲解时会对比着Callable、Runnable、Future来讲。

这些组件使用场景相对AQS会少一些,但也是J.U.C的重要组成部分,也是需要掌握的

线程调度-线程池

J.U.C里最后一部分:线程池。面试大概率会问到线程池相关的知识点。

这一章将主要从new Thread弊端、线程池的好处、ThreadPoolExecutor详细介绍(参数、状态、方法)、线程池类图、Executor框架接口等进行讲解,需要大家能了解线程池的许多细节及配置,并能在实际项目中正确使用

多线程并发拓展讲解

对并发编程做些补充,但都贴近当前的面试,主要讲解死锁产生的条件及预防、多线程并发编程的最佳实践、Spring与线程安全、以及面试都特别喜欢问的HashMap和ConcurrentMap源码细节。当然,面试喜欢问的问题,对实际项目开发也是特别重要的

高并发之扩容

高并发部分:思路,侧重面试,扩容思路,首先介绍垂直扩容和水平扩容的区别,之后介绍数据库读操作扩展和写操作扩展思路。

高并发之缓存

思路,本章讲解高并发中缓存方案。

包含对缓存特征(命中率、最大元素、清空策略)、影响缓存命中率因素、缓存分类和应用场景(本地缓存、分布式缓存)、高并发场景下缓存常见问题(缓存一致性、缓存并发、缓存穿透、雪崩)等的具体介绍。此外,针对大家常用的缓存组件Guava Cache、Memcache、Redis

高并发之消息队列

思路,本章介绍了消息队列的特性(业务无关、FIFO、容灾、性能)、为什么需要消息队列以及消息队列的好处(业务解耦、最终一致性、广播、错峰与流控),最后对当前比较流行的消息队列组件kafka和rabbitmq做了架构分析和特性介绍

高并发之应用拆分

从实际项目拆分步骤讲起,让大家可以实际感受到应用拆分的好处和解决的问题,之后引出对应用拆分原则(业务优先、循序渐进、兼顾技术、可靠测试)和应用拆分时思考的内容(应用之间通信、应用之间数据库设计、避免事务跨应用),并引出对服务化Dubbo和微服务Spring Cloud的框架介绍

高并发之应用限流

思路,本章从实际项目保存百万数据的限流场景开始讲起,让大家感受一下某些高并发场景下使用限流和不使用限流的区别,明确限流的重要作用

之后详细介绍了限流常用的四种算法:计数法、滑动窗口、漏桶算法和令牌桶算法,并对他们做了简单的对比

服务降级与服务熔断

通过举例让大家明白什么是服务降级和服务熔断

之后介绍了服务降级的分类:自动降级(超时、失败次数、故障、限流)和人工降级(开关),总结了服务降级和服务熔断的共性(目的、最终表现、粒度、自治)和区别(出发原因、管理目标层次、实现方式)以及服务降级要考虑的问题

最后介绍了Hystrix

数据库分库分表与高可用手段

高并发部分:主讲思路,从数据库瓶颈开始讲起,引出对数据库切库分库分表的介绍。数据库切库里重点介绍了读写分离的设计,对比支持多数据源和分库的区别;

最后介绍了什么时候该考虑分表、横向分表与纵向分表,以及通过mybatis的分页插件shardbatis2.0实现数据库分表

之后介绍了高可用的三个常用手段:任务调度系统分布

知识体系总结

对知识进行总结回顾,希望大家都能有所收获,并期待与大家共同探讨并发与高并发的话题

参考

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Java 高并发多线程编程系列 demo 案例代码 & 教程 & 面试题集锦! !! 包括但不限于线程安全性, atomic包下相关类、CAS原理、Unsafe类、synchronized关键字等的使用及注意事项,volatile关键字的规则和使用,及synchronized关键字的可见性,happens-before原则 安全发布对象的一些核心方法方式,线程安全策略定义不可变对象、线程封闭、同步容器、并发容器等.\,AQS模型设计及相关同步组件的原理和使用,都非常实用,具体包括:CountDownLatch、Semaphore、CyclicBarrier、ReentrantLock与锁、Condition等,FutureTask、Fork/Join框架、BlockingQueue,其... 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/c_d_m/Java-Concurrency-Progamming-Tutorial.git
git@gitee.com:c_d_m/Java-Concurrency-Progamming-Tutorial.git
c_d_m
Java-Concurrency-Progamming-Tutorial
Java-Concurrency-Progamming-Tutorial
master

搜索帮助