
并发
这个昵称有十五个字不信你数数
我有点可爱哈哈哈哈哈哈哈
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode 1115] 交替打印FooBar
[LeetCode 1115] 交替打印FooBar 我们提供一个类: class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for (int i = 0; i < n; i++) { print("bar"); } } } 两个不同的线程将会共用一个 FooBar原创 2020-10-08 12:24:48 · 308 阅读 · 0 评论 -
java volatile 关键字
定义: volatile关键是声明的变量表示有其他线程可能会更改该变量的值,所以各线程对于volatile定义的变量必须从主存中获取,而不能通过缓存中获取,但是volatile字段是非阻塞的,即无锁的,也就是说,它只保证每次从主存中获取数据,但是不能让read-update-write过程是成为一个原子操作,这也是它和Synchronized关键字的一个重要区别。 实例: public ...原创 2019-09-10 10:35:38 · 163 阅读 · 0 评论 -
[LeetCode] 1115. Print FooBar Alternately
Suppose you are given the following code: class FooBar { public void foo() { for (int i = 0; i < n; i++) { print("foo"); } } public void bar() { for (int i = 0; i < n;...原创 2019-09-11 12:03:24 · 406 阅读 · 0 评论 -
[LeetCode] 1116. Print Zero Even Odd
Suppose you are given the following code: class ZeroEvenOdd { public ZeroEvenOdd(int n) { ... } // constructor public void zero(printNumber) { ... } // only output 0's public void even(p...原创 2019-09-12 17:58:11 · 610 阅读 · 0 评论