Java线程什么时候空闲? [英] When is a Java thread idle?

查看:411
本文介绍了Java线程什么时候空闲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需通过Java 为什么没有空闲状态?还是最能代表空闲线程的状态是什么?
RUNNING是但不是在CPU上执行吗?

How come there is no idle state? Or what state most closely represents an idle thread?
Is RUNNING but just not executing on CPU?

推荐答案

BLOCKED线程是对慢速和/或共享资源进行调用的线程.由于线程直到调用返回才能继续执行,因此该线程处于空闲状态.

A BLOCKED thread is one that has made a call to slow and/or shared resource. Since the thread cannot continue until the call returns, the thread is idle.

WAITING和TIMED_WAITING是当线程正在等待另一个线程(而不是某些资源)时,它将处于空闲状态,直到另一个线程允许它恢复.

WAITING and TIMED_WAITING is when the thread is waiting for another thread (as opposed to some resource), and will be idle until the other thread allows it to resume.

NEW尚未被安排在CPU上.它本质上是可运行的,但这指出了它是刚创建的.我个人不会认为这是闲置的.

NEW merely has not been scheduled on a CPU yet. It is essentially RUNNABLE, but this points out the fact that it was just created. I personally would not consider this idle.

RUNNABLE表示它正在运行或正在等待分配给CPU.

RUNNABLE means it is either running, or is waiting to be assigned to a CPU.

这篇关于Java线程什么时候空闲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆