2021年3月9日
摘要: TCP 用户传输协议,连接稳定,三次握手,四次挥手 服务器端代码 import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import java.net.ServerSock 阅读全文
posted @ 2021-03-09 19:59 要给小八赚罐头钱 阅读(58) 评论(0) 推荐(0)
摘要: 网络编程Port-InetSocketAddress 端口有0-65535 tcp和udp所占端口可以相同,各走一套 公用端口:0-1023 别用 http 80 https 443 ftp 21 Telent 23 程序注册端口:1024-49151 Tomcat 8080 MySQL 3306 阅读全文
posted @ 2021-03-09 11:53 要给小八赚罐头钱 阅读(55) 评论(0) 推荐(0)
摘要: 网络编程IP-InetAddress import java.net.InetAddress;import java.net.UnknownHostException;​public class TestIP { public static void main(String[] args) { tr 阅读全文
posted @ 2021-03-09 11:19 要给小八赚罐头钱 阅读(45) 评论(0) 推荐(0)
  2021年3月8日
摘要: 线程锁lock package com.peanutist.day10;​import com.sun.org.apache.bcel.internal.generic.NEW;​import java.util.concurrent.locks.Lock;import java.util.conc 阅读全文
posted @ 2021-03-08 23:48 要给小八赚罐头钱 阅读(81) 评论(0) 推荐(0)
摘要: 线程池ExecutorService ExecutorService才是真正的线程池接口 import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;​public class TestExecu 阅读全文
posted @ 2021-03-08 23:25 要给小八赚罐头钱 阅读(35) 评论(0) 推荐(0)
摘要: 保证线程安全-信号灯法 设立flag,一个线程flag=true时跑,另一个线程wait(),跑完了告诉另外一个线程可以跑了notifyAll() public class TestThreadWait2 { public static void main(String[] args) { TV t 阅读全文
posted @ 2021-03-08 23:12 要给小八赚罐头钱 阅读(40) 评论(0) 推荐(0)
摘要: 管程法 this.wait();让该线程等待 this.notifyAll();让另外线程开始 public class TestThreadWait { public static void main(String[] args) { SynContainer synContainer = new 阅读全文
posted @ 2021-03-08 22:21 要给小八赚罐头钱 阅读(128) 评论(0) 推荐(0)
摘要: 线程同步方法synchronized synchronized修饰需要控制资源的方法。 public class TestSynchronized { public static void main(String[] args) { BuyTicket buyTicket = new BuyTick 阅读全文
posted @ 2021-03-08 20:52 要给小八赚罐头钱 阅读(31) 评论(0) 推荐(0)
  2021年3月7日
摘要: 守护线程daemon 线程分为用户线程(正常都是用户线程)和守护线程。 虚拟机要等用户线程,不等守护线程。 setDaemon是boolean值,默认是false public class TestThreadDaemon { public static void main(String[] arg 阅读全文
posted @ 2021-03-07 22:38 要给小八赚罐头钱 阅读(34) 评论(0) 推荐(0)
摘要: public class TestThreadPriority { public static void main(String[] args) { System.out.println(Thread.currentThread().getName()+"-->的优先级是"+Thread.curre 阅读全文
posted @ 2021-03-07 21:58 要给小八赚罐头钱 阅读(55) 评论(0) 推荐(0)