- 博客(4)
- 资源 (16)
- 收藏
- 关注
原创 Java泛型中? extends E和? super E的区别
这篇文章谈一谈Java泛型声明<? extends E>和<? super E>的作用和区别<? extends E> <? extends E> 是 Upper Bound(上限) 的通配符,用来限制元素的类型的上限,比如List<?extendsFruit>fruits;表示集合中的元素类型上限为Fruit类型,即只能是Fruit或者Fruit的子类,因此对于下面的赋值是合理的fruits=n...
2020-06-26 09:07:45 847
原创 3.线程间的通信
前记:师夷长技以自强1.用轮询实现的线程间通信机制如下:import java.util.ArrayList;import java.util.List;class MyList{ private List list = new ArrayList(); public void add(){ list.add("haha"); } public int size(){ return list.size(); }}cl
2020-06-09 21:58:23 420 1
原创 2.变量的并发访问
前记:师夷长技以自强1.问题背景在上一篇文章中我们已经讨论了线程具有异步运行的特性,因此当多线程同时访问同一个实例变量时就会引发脏读的问题。而这显然不是我们愿意看到的,解决办法也很简单,就是给访问该变量的程序部分加锁。多线程并发在一些追求效率的系统中常存在变量不可见的问题,由于变量的不可见也会导致程序运行的结果不是我们想要的。一句话,同步性和可见性问题是多线程中的两大重点内容,他们分别对应于synchronized和volitle关键字的使用。本文主要围绕了在各种情况下如何使用这两个关键字而展开的。2
2020-06-07 23:44:55 340 1
原创 1.多线程使用基础
1.JDK中支持的类和接口Thread:线程类的声明部分如下:public class Threadextends Objectimplements Runnable可以看出Thread是一个直接继承自Object的类,并且实现了Runnable接口。根据JDK文档可知,创建一个线程的方式有两种:(1)继承Thread类;(2)把实现Runnable接口的类的对象作为Thread类构造函数参数。ex1(继承):public class ThreadInheri { publi
2020-06-05 17:54:59 258
Approximation Algorithms.rar
2020-04-26
牛津字典(欧路词典).txt
2020-03-29
STL_帮助文档
2016-11-26
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人