线程
普通小程序员
这个作者很懒,什么都没留下…
展开
-
创建线程之二------实现Runnable接口
package cn.thread; /** * 创建线程之------实现Runnable接口 * 1:创建线程类实现Runnable接口,覆盖run方法 2:使用匿名函数创建线程 * * @author Administrator * */ public class TestRunnable { /* * public static void main(String...原创 2019-11-26 20:31:17 · 104 阅读 · 0 评论 -
创建线程之一 ----------继承thread类
package cn.thread; /** * 创建线程之----------继承thread类 * 1:创建线程类 * 2:使用匿名函数创建线程 * @author Administrator * */ public class TestThread { /** * 1:创建线程类 * @param args */ public static void ma...原创 2019-11-26 20:30:31 · 143 阅读 · 0 评论 -
创建线程之三----使用 FutureTask 实现有返回结果的线程
@ Example1FutureTask 的简单例子 public class Test { public static void main(String[] args) throws InterruptedException, ExecutionException { FutureTask<Double> task = new FutureTask(new My...转载 2019-11-26 20:29:20 · 239 阅读 · 0 评论 -
线程的让步与阻塞
线程的让步: 线程让步 Thread.yield() public class TestYield { public static void main(String[] args) { Person p=new Person(); Thread t1=new Thread(p); Thread t2=new Thread(p); ...原创 2019-09-12 17:07:26 · 103 阅读 · 0 评论