线程
_蒹葭苍苍
Everyone has his own dreams.My dream is to be a computer programmer.I think it's very interesting and exciting for me to work on.With the development of science and technology,people can imagin and swim freely in the world ofcomputers.Computers have become good partners and friends in the daily life
展开
-
请说出与线程同步以及线程调度相关的方法
- wait():使一个线程处于等待(阻塞)状态,并且释放所持有的对象的锁; - sleep():使一个正在运行的线程处于睡眠状态,是一个静态方法,调用此方法要处理InterruptedException异常; - notify():唤醒一个处于等待状态的线程,当然在调用此方法的时候,并不能确切的唤醒某一个等待状态的线程,而是由JVM确定唤醒哪个线程,而且与优先级无关; - notityAl...原创 2018-10-22 10:25:42 · 675 阅读 · 1 评论 -
启动一个线程是调用run()还是start()方法?
启动一个线程是调用start()方法,使线程所代表的虚拟处理机处于可运行状态,这意味着它可以由JVM 调度并执行,这并不意味着线程就会立即运行。 run()方法是线程启动后要进行回调(callback)的方法。...原创 2018-10-22 11:19:27 · 3163 阅读 · 0 评论 -
什么是线程池以及它的作用是什么?
概述 到目前为止我们使用多线程应用程序的目的是尽可能多地使用计算机处理器资源。所以,看起来我们仅需要为每个独立的任务分配一个不同的线程,并让处理器确定在任何时间它总会处理其中的某一个任务。额,对小系统来说这样做很好。但是当系统越来越复杂时,线程的数量也会越来越多,操作系统将会花费更多时间处理锁分配,理清线程之间的关系,处理程序指令的时间实际上是很少的。为了让我们的程序具备可扩展性,我们将不得不对...原创 2018-10-23 19:09:18 · 2176 阅读 · 0 评论