-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.xml
More file actions
81 lines (68 loc) · 7.12 KB
/
Copy pathindex.xml
File metadata and controls
81 lines (68 loc) · 7.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>阿飞的博客</title>
<link>http://afei.website/</link>
<description>Recent content on 阿飞的博客</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-Hans</language>
<lastBuildDate>Fri, 25 Oct 2019 22:06:17 +0800</lastBuildDate>
<atom:link href="http://afei.website/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>多线程与并发原理</title>
<link>http://afei.website/posts/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8E%E5%B9%B6%E5%8F%91%E5%8E%9F%E7%90%86/</link>
<pubDate>Fri, 25 Oct 2019 22:06:17 +0800</pubDate>
<guid>http://afei.website/posts/%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8E%E5%B9%B6%E5%8F%91%E5%8E%9F%E7%90%86/</guid>
<description>多线程与并发原理 为什么需要多线程 多线程就类似N个工人在同一时间去干同一件事, 也叫线程并发执行, 效率高 这个同一时间指的是同一秒里面, CPU在这一毫秒执行了A线程, 然后下一毫秒挂起A线程, 执行B线程, 然后这样交替执行完AB线程, 就是并发结束 多线程带来了什么问题, 如何避免 多线程带来了线程不安全性, 也就是因为很多线程乱序执行同一个程序, 导致结果和单线程执行结果不一致
解决方案:
选择避免共享资源 如果不能避免共享资源, 保证共享资源的原子性和一致性 synchronized 同步机制 Lock 线程的属性、状态 线程属性 线程的属性有以下这些: 线程优先级, 守护线程, 处理未捕获异常的处理器
1.线程优先级
每个线程都有一个优先级, 在不处理时, 默认优先级都相同, 优先级分成1-10, 高优先级的线程会先被操作
2.守护线程
t.setDaemon(true); //将线程转换为守护线程 守护线程的作用是为其他线程提供服务, 如果其他所有线程被退出, 那守护线程就结束了,例如其他线程的计时器, 可以是守护线程
3.处理未捕获异常的处理器
run方法抛出任何异常会导致线程终止, 在这种情况下, 我们需要实现一个Thread.UncaughtExceptionHandler。我们可以通过这种方式来知道,真正让我们的run意外死亡的问题在哪里
线程状态 线程一共有6中状态, 分别是New , Runnable, Blocked, Waiting, Timed waiting, Terminated
1. New 新创建的线程
new Thread(r) 指刚刚new 出来的线程, 这个线程没有通过start方法启动</description>
</item>
<item>
<title>Collection体系和常用实现类</title>
<link>http://afei.website/posts/collection%E4%BD%93%E7%B3%BB%E5%92%8C%E5%B8%B8%E7%94%A8%E5%AE%9E%E7%8E%B0%E7%B1%BB/</link>
<pubDate>Mon, 21 Oct 2019 22:07:58 +0800</pubDate>
<guid>http://afei.website/posts/collection%E4%BD%93%E7%B3%BB%E5%92%8C%E5%B8%B8%E7%94%A8%E5%AE%9E%E7%8E%B0%E7%B1%BB/</guid>
<description>Collection体系和常用实现类 Collection继承体系 // 常用实现: ArrayList List&lt;Integer&gt; list = new ArrayList&lt;&gt;(); for(int i = 0; i&lt; list.size(); i++) { list.get(i); } // 常用实现: LinkedHashSet Collect c = new LinkedHashSet(); List&lt;Integer&gt; list = new ArrayList&lt;&gt;(c); //等价于 List&lt;Integer&gt; list2 = new ArrayList&lt;&gt;(); list2.addAll(c); //等价于 List&lt;Integer&gt; list3 = new ArrayList&lt;&gt;(); for(Integer i : c){ list3.add(i); } list.add(1); list.add(2); //不停的加 List 最常用的ArrayList 本质上是一个数组 面试题: 动态扩容的实现 创建一个更大的空间, 然后把原先的所有元素拷贝过去 旧的容量=数组的长度</description>
</item>
<item>
<title>Maven的包管理和包冲突</title>
<link>http://afei.website/posts/maven%E7%9A%84%E5%8C%85%E7%AE%A1%E7%90%86%E5%92%8C%E5%8C%85%E5%86%B2%E7%AA%81/</link>
<pubDate>Fri, 18 Oct 2019 22:47:09 +0800</pubDate>
<guid>http://afei.website/posts/maven%E7%9A%84%E5%8C%85%E7%AE%A1%E7%90%86%E5%92%8C%E5%8C%85%E5%86%B2%E7%AA%81/</guid>
<description>Maven的包管理和包冲突 JVM的工作 加载字节码,执行一个类 如果碰到新的类, 加载它
在哪里可以找到类
-classpath / -cp 类的全限定类名(目录层级) 唯一确定了一个类
包就是把许多类放在一起压缩的jar
传递性依赖
依赖的这个类还依赖别的类 classpath hell classpath中有两个完全一样的jar包但版本不同, 而引用了老的版本, 某一天系统崩溃 当多个同名类出现在classpath就是噩梦的开始 包管理 包管理的本质就是告诉JVM如何找到所需要的第三方类库 以及成功的解决冲突问题 scope test测试代码不会被发布出去, scope为test 编译时有效,运行时无效, scope为provided Maven 约定优于配置 严格按照层次管理 四个属性: groupid, artifactid, version,scope 分别是组id , 包名id, 版本号, 类别 传递性依赖的自动管理 原则:绝对不允许最终的classpath出现同名不同版本的jar包 依赖冲突的解决 原则:最近的胜出,同样近时先出现的胜出 依赖的scope 包冲突异常 AbstractMethodError NoClassDefFoundError ClassNotFoundException LinkageError 上面这个情况是同名jar和你的项目一样近,先出现的C1胜出</description>
</item>
<item>
<title>单例模式</title>
<link>http://afei.website/posts/%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/</link>
<pubDate>Fri, 18 Oct 2019 00:08:32 +0800</pubDate>
<guid>http://afei.website/posts/%E5%8D%95%E4%BE%8B%E6%A8%A1%E5%BC%8F/</guid>
<description> 单例模式 需求: 只创建一个对象, 不需要第二个
public class World { private static final World SINGLETON_INSTANCE = new World(); public static World getInstance() { return SINGLETON_INSTANCE; } private World() { } } final修饰一个实例, 作为静态成员
静态工厂方法, 返回这个静态成员
把构造器改成private
</description>
</item>
<item>
<title>如何使用Hugo搭建博客</title>
<link>http://afei.website/posts/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8hugo%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/</link>
<pubDate>Fri, 18 Oct 2019 00:08:32 +0800</pubDate>
<guid>http://afei.website/posts/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8hugo%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2/</guid>
<description>如何使用Hugo搭建博客 1.安装Hugo(windows) 在Hugo页面下载Hugo, 并且解压到C:\Hugo 2.设置环境变量 右键我的电脑-属性-高级系统设置-环境变量-新建 设置PATH - 新建 - %HUGO% 验证是否安装设置成功 3. 建立网站 hugo new site quickstart 将上面的代码在文件夹中创建一个新的Hugo网站quickstart
4. 添加主题 cd quickstart # Download the theme git init git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke # Note for non-git users: # - If you do not have git installed, you can download the archive of the latest # version of this theme from: # https://github.</description>
</item>
</channel>
</rss>