![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java
使用Java语言编程
肾里的潇洒情
helloworld
展开
-
Thread
Thread 的 interrupt 函数public void Thread.interrupt() // 中断线程public boolean Thread.isInterrupted() // 判断是否被中断public static boolean Thread.interrupted() // 判断是否被中断,并清除当前中断状态// 中断响应方法Thread t1 = new Thread(() -> { while(true) { if(Thread.curren原创 2021-05-29 22:50:44 · 252 阅读 · 0 评论 -
java8 函数式编程-记录
一个函数能作为另一个函数的返回值不同的写法,相同的结果//jdk 1.8之前public static void a() { int[] arr = {1,2,3,4,5,6}; for(int i=0;i<arr.length;i++) { System.out.print(arr[i]+1); }}//jdk 1.8之后public static void b() { int[] arr = {1,2,3,4,5,6}; Arrays.stream(arr).map(x原创 2021-05-28 15:12:30 · 133 阅读 · 0 评论 -
Java高并发程序设计-记录
使容器线程安全Collections提供了一些让线程安全的函数jdk 1.8Collections.synchronizedMap(new HashMap<>());...Collections.synchronizedSet(new HashSet<>());比如 Collections.synchronizedMap(new HashMap<>()) 它通过传入的对象实例化Collections的子类SynchronizedMap的每一个方法,在通过获取原创 2021-05-27 20:37:33 · 97 阅读 · 0 评论 -
TrayIcon Demo
public class MyTrayIcon { private static TrayIcon trayIcon; private static MouseListener mouseListener;// 托盘图标鼠标事件监听 static { PopupMenu popupMenu = new PopupMenu(); MenuItem open = new MenuItem("method"); MenuItem quit =原创 2021-05-20 10:47:16 · 122 阅读 · 0 评论 -
SocketChannel Demo
Serverpublic class Server { static int capacity = 1024*10; public void open() throws IOException { Selector selector = Selector.open(); ServerSocketChannel serverSocketChannel = ServerSocketChannel.open().bind(new InetSocketAddress(9999)); serverS原创 2021-05-19 14:24:46 · 146 阅读 · 0 评论 -
Socket 单线程 多文件传输
Clientpublic class Client { private String parentPath; public void open() { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileChooser.setDialogTitle("选择文件上传"); fi原创 2021-05-13 22:37:28 · 203 阅读 · 0 评论 -
Socket 多线程 多文件传输
Serverpublic class Server { private String savePath = "c:/";// 保存路径 public void open() throws IOException { ServerSocket server = new ServerSocket(8088); while(true) { Socket socket = server.accept(); System.out.prin原创 2021-05-13 08:41:24 · 373 阅读 · 0 评论