上一页 1 2 3 4 5 6 ··· 24 下一页
摘要: /** * T12_ForkJoinPool 分而治之 * Fork: 分叉 * Join: 合并 * * 将一个任务拆分多个任务执行(可以无限切分),然后将结果合并 * * 比如大量的并行计算, 如下: 求100_0000个数字之和, 使用多线程 */ public class T12_ForkJoinPool { static int[] nums = n... 阅读全文
posted @ 2019-10-22 14:53 我爱si搬砖 阅读(167) 评论(0) 推荐(0) 编辑
摘要: /** * ScheduledPool * Scheduled: 计划中的,定时的 * 执行定时的任务,类似Delay, 可以替代Timer */ public class T10_ScheduledPool { public static void main(String[] args) { ScheduledExecutorService service... 阅读全文
posted @ 2019-10-22 14:49 我爱si搬砖 阅读(571) 评论(0) 推荐(0) 编辑
摘要: /** * SingleThreadPool * 线程池中只有一个线程 * 作用,保证线程执行的时序性 */ public class T09_SingleThreadPool { public static void main(String[] args) { ExecutorService service = Executors.newSingleThr... 阅读全文
posted @ 2019-10-22 14:46 我爱si搬砖 阅读(316) 评论(0) 推荐(0) 编辑
摘要: /** * CachedThreadPool * 可缓存的线程 * 当有个请求进入线程池内, 线程池将会启用一个线程 * 当再次有个请求进入线程池内, 并且上个线程未结束, 仍然会启用一个线程 * 当有线程执行完毕后,这个线程不会被清除, 而是被缓存,当有请求进入时, 直接使用缓存线程调用 * 跟 fixedThreadPool 类似, 只不过没有上限(最多Integer最大值... 阅读全文
posted @ 2019-10-22 14:44 我爱si搬砖 阅读(555) 评论(0) 推荐(0) 编辑
摘要: /** * T12_ForkJoinPool 分而治之 * Fork: 分叉 * Join: 合并 * * 将一个任务拆分多个任务执行(可以无限切分),然后将结果合并 * * 比如大量的并行计算, 如下: 求100_0000个数字之和, 使用多线程 */ public class T12_ForkJoinPool { static int[] nums = new int[100_0000]; s 阅读全文
posted @ 2019-10-22 14:40 我爱si搬砖 阅读(387) 评论(0) 推荐(0) 编辑
摘要: /** * WorkStealingPool * 工作窃取线程池 * * 假设共有三个线程同时执行, A, B, C * 当A,B线程池尚未处理任务结束,而C已经处理完毕,则C线程会从A或者B中窃取任务执行,这就叫工作窃取 * 假如A线程中的队列里面分配了5个任务,而B线程的队列中分配了1个任务,当B线程执行完任务后,它会主动的去A线程中窃取其他的任务进行执行 * WorkStealingPool 阅读全文
posted @ 2019-10-22 14:39 我爱si搬砖 阅读(3307) 评论(1) 推荐(0) 编辑
摘要: --单行函数:作用于一行,返回一个值--字符函数select upper(deptno),loc from dept;--结果转大写select lower(loc),loc from dept;--结果转小写select substr(loc,0,3),loc from dept--从第0位置开始 阅读全文
posted @ 2019-10-20 22:29 我爱si搬砖 阅读(133) 评论(0) 推荐(0) 编辑
摘要: /** * 线程池的作用:并行计算 * 计算 1-200000 之间的质数 */ public class T07_ParallelComputing { public static void main(String[] args) throws ExecutionException, InterruptedException { long start =... 阅读全文
posted @ 2019-10-18 20:14 我爱si搬砖 阅读(196) 评论(0) 推荐(0) 编辑
摘要: /** * Future 未来的执行结果 */ public class T06_Future { public static void main(String[] args) throws ExecutionException, InterruptedException { // 未来任务, 既是Runnable 也是 Future Fut... 阅读全文
posted @ 2019-10-18 19:40 我爱si搬砖 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 线程池的作用:并行计算 阅读全文
posted @ 2019-10-18 19:27 我爱si搬砖 阅读(314) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 24 下一页