随笔分类 - java
摘要:三大方法,七大参数,四种拒绝策略 三大方法 ExecutorService threadPool = Executors.newSingleThreadExecutor();//单个线程 ExecutorService threadPool2 = Executors.newFixedThreadPo
阅读全文
摘要:阻塞队列 阻塞 写入:如果队列中数据满了,就得阻塞等待 读取:如果队列中无数据,就得阻塞等待 队列 队列遵循FIFO规则 BlockingQueue族谱 BlockingQueue 四种API(四种方法) 方式 抛出异常 不抛异常,正常返回值 阻塞等待 超时等待 添加 add offer put o
阅读全文
摘要:/** * 独占锁(写锁):一次只能被一个线程占用 * 共享锁(读锁):多个线程可以同时占有 * ReadWriteLock 是接口 ReentrantReadWriteLock是他的一个实现类 * 读-读: 可以共享 * 读-写: 不可共享 * 写-写: 不可共享 */ public class
阅读全文
摘要:public class Test { public static void main(String[] args) throws ExecutionException, InterruptedException { new Thread1().start(); new Thread(new Thr
阅读全文
摘要:List不安全 List: //java.util.ConcurrentModificationException 并发修改异常! public class ListTest { public static void main(String[] args) { List<Object> arrayL
阅读全文
摘要:CountDownLatch的使用 /* 减法计数器 */ public class Test1 { public static void main(String[] args) throws InterruptedException { CountDownLatch countDownLatch
阅读全文
摘要:1.1 概述 计算机网络 计算器网络是将地理位置不同的具有独立功能的多台计算机及其外部设备,通过通信线路连接起来,在网络操作系统,网络管理软件及网络通信协议的管理和协商下,实现资源共享和信息传递功能的计算机系统 网络编程目的 数据交换,通信 需要怎么做 如何准确地定位网络上的一台主机:IP地址和端口
阅读全文
摘要:String param = null; switch (param){ case "null":{ System.out.println("null"); break; } default :{ System.out.println("default"); } } 出现错误:Exception i
阅读全文
摘要:File 1.创建File new File(String pathname) //根据路径直接创建File对象(创建在内存中,调用createNewFile()才能在磁盘创建) new File(File parent,String child) //根据父目录文件+子路径构建 new File(
阅读全文
摘要:集合只能存储引用数据类型 COllection 方法: 迭代器的使用遍历集合: Iterator<Person> iterator = list.iterator(); while(iterator.hasNext()){ System.out.println(iterator.next()); }
阅读全文
摘要:1.外部类与内部类 1.成员内部类 一个类里边定义另外一个类,里边的类就叫内部类,外边的就叫外部类 内部类可以访问外部类的成员,即使是私有的。但是要想创建内部类之前就必须先创建外部类。 public class Outer { private int id = 10; void show(){ Sy
阅读全文
摘要:1 简介 图形用户界面(Graphical User Interface,简称 GUI,又称图形用户接口)是指采用图形方式显示的计算机操作用户界面。 Gui的核心技术: Swing AWT 因为界面不美观 需要jre环境 为什么我们要学习? 可以写出自己心中想要的小工具 工作时候,也可能需要维护到s
阅读全文