多线程
文章平均质量分 56
自带五拨片
编写有思想的代码,是我一生的追求!
展开
-
Redis缓存一致问题(延迟双删)
Redis实现延迟双删存在的问题原创 2022-04-12 14:47:34 · 890 阅读 · 0 评论 -
线程的中断
今天,在学习线程中断的过程中,学到了之前不知道的新知识。线程中断避免使用Thread提供的stop()方法。正确的方法是使用interrupt()方法,案例如下: public class MyRunnable implements Runnable { public static void main(String[] args) throws ExecutionException, ...原创 2020-03-04 00:04:57 · 284 阅读 · 1 评论 -
实现多线程的几种方法
一。通过继承Thread类实现多线程 继承Thread类,并覆盖父类的run()方法。如下例子: public class MyThread extends Thread { public static void main(String[] args) { new MyThread().start(); } @Override public v...原创 2020-03-03 19:35:08 · 196 阅读 · 0 评论 -
synchronized用法
一。synchronized是保证线程安全的一种方法。它实现的功能有两种锁: 1.类锁 (1)synchronized修饰成员方法 例如: public synchronized void run(){ try { Thread.sleep(5000); } catch (InterruptedException e) { ...原创 2020-03-02 12:36:04 · 296 阅读 · 0 评论