当前位置:网站首页>【高并发】关于线程池,蚂蚁金服面试官问了我这些内容!!
【高并发】关于线程池,蚂蚁金服面试官问了我这些内容!!
2022-06-11 09:51:00 【InfoQ】
面试汇总
Java中的线程池是如何实现的?
创建线程池的几个核心构造参数?
- corePoolSize:线程池的核心线程数。
- maximumPoolSize:线程池允许的最大线程数。
- keepAliveTime:超过核心线程数时闲置线程的存活时间。
- workQueue:任务执行前保存任务的队列,保存由execute方法提交的Runnable任务。
线程池中的线程是怎么创建的?是一开始就随着线程池的启动创建好的吗?
既然提到可以通过配置不同参数创建出不同的线程池,那么Java中默认实现好的线程池又有哪些呢?请比较它们的异同。
corePoolSize:1,只有一个核心线程在工作。
maximumPoolSize:1。
keepAliveTime:0L。
workQueue:newLinkedBlockingQueue<Runnable>(),其缓冲队列是无界的。
corePoolSize:nThreads
maximumPoolSize:nThreads
keepAliveTime:0L
workQueue:newLinkedBlockingQueue<Runnable>(),其缓冲队列是无界的。
corePoolSize:0
maximumPoolSize:Integer.MAX_VALUE
keepAliveTime:60L
workQueue:newSynchronousQueue<Runnable>(),一个是缓冲区为1的阻塞队列。
corePoolSize:corePoolSize
maximumPoolSize:Integer.MAX_VALUE
keepAliveTime:DEFAULT_KEEPALIVE_MILLIS
workQueue:newDelayedWorkQueue()
- execute()、ExecutorService.execute方法接收一个Runable实例,它用来执行一个任务。
- submit()、ExecutorService.submit()方法返回的是Future对象。可以用isDone()来查询Future是否已经完成,当任务完成时,它具有一个结果,可以调用get()来获取结果。也可以不用isDone()进行检查就直接调用get(),在这种情况下,get()将阻塞,直至结果准备就绪。Java内存模型相关问题
什么是Java的内存模型,Java中各个线程是怎么彼此看到对方的变量的?
请谈谈volatile有什么特点,为什么它能保证变量对所有线程的可见性?
既然volatile能够保证线程间的变量可见性,是不是就意味着基于volatile变量的运算就是并发安全的?
请对比下volatile对比Synchronized的异同。
请谈谈ThreadLocal是怎么解决并发安全的?
很多人都说要慎用ThreadLocal,谈谈你的理解,使用ThreadLocal需要注意些什么?
边栏推荐
- 不同CV任务的标注类型
- 图片规则翻页
- Esp8266 Smartconfig
- Q1 revenue exceeded expectations. Why did man Bang win headwind growth?
- 帝国CMS仿《游戏鸟》模板源码/92kaifa版大型手机游戏门户网站模板
- 浅谈wandfluh比例阀的功能与作用
- ORA-00059 超过db_files限制
- ESP8266_ Connect to Alibaba cloud through mqtt protocol
- Where is it safer to open an account for soda ash futures? How much do you need to buy at least?
- P1169 "chessboard making"
猜你喜欢

An error will be reported when the RAC modifies the scanip to different network segments

你对软件兼容性测试知道多少?如何选择软件兼容性测试机构?

parker派克先导式电磁阀和直动式电磁阀的区别有哪些?

What are the functions and applications of Mogg test controller

Integer lifting example

js基础--关于DOM

Tenthousand words thoroughly learn heap and binary tree

Opencv image basic operation (III) -- image feature extraction (corner detection)

rac expdp导出时报错:ORA-31693、ORA-31617、ORA-19505

赛灵思引脚约束文件 .xdc
随机推荐
EMG执行器的作用和功能有哪些
Leetcode brushing questions - hand tearing binary tree
steamVR简介
我们是如何连上WiFi的?
js基础--关于DOM
Tenthousand words thoroughly learn heap and binary tree
New feature in ES6 -- arrow function
Redis transaction details
jedisLock—redis分布式锁实现
Using exec in PHP to display errors
php 中使用exec显示报错
js基础--运算符
Servlet 的初次部署
Oracle 11g RAC disk group has space and cannot add data files?
Can station B make money?
远程工作时代的物联网安全
数据一致的问题
锐意进取,砥砺前行,JASMINER持续深耕品牌实力
Technology cloud report: privacy computing under the wave of Web3.0
「INS-30131」 安装程序验证所需的初始设置失败