this.getstate

线程类Thread.State getState() (Thread Class Thread.State getState())

  • This method is available in package java.lang.Thread.getState().

    软件包java.lang.Thread.getState()中提供了此方法。

  • This method is used to return the state of this thread.

    此方法用于返回此线程的状态。

  • When we execute a thread so there are various states for normal execution of the thread [States of the Thread like, start, ready, running, waiting, blocked, terminate].

    当我们执行一个线程时,有多种状态可以正常执行该线程[线程的状态,如启动,就绪,运行,等待,阻塞,终止]。

  • This method is not final so we can override this method in child class.

    此方法不是最终方法,因此我们可以在子类中重写此方法。

  • The return type of this method is Thread.State so it returns the state of this thread

    此方法的返回类型为Thread.State,因此它返回此线程的状态。

  • This method does not raise any exception.

    此方法不会引发任何异常。

Syntax:

句法:

    Thread.State getState(){
}

Parameter(s):

参数:

We don't pass any object as a parameter in the method of the Thread.

我们不会在Thread方法中将任何对象作为参数传递。

Return value:

返回值:

The return type of this method is Thread.State, it returns the state of this thread.

该方法的返回类型为Thread.State ,它返回此线程的状态。

Java程序演示getState()方法的示例 (Java program to demonstrate example of getState() method)

/*  We will use Thread class methods so we are importing
the package but it is not mandate because
it is imported by default
*/
import java.lang.Thread;
class GetThreadState extends Thread {// Override run() of Thread class
public void run() {// By using getState() method is used to return
// the state of this thread
System.out.println("The state of this thread is : " + Thread.currentThread().getState());
/* This is another way of writing the above statement
Thread.State th_state = Thread.currentThread().getState();
System.out.println("The state of this thread is : "+th_state);*/
}
public static void main(String[] args) {// Creating an object of GetThreadState class
GetThreadState gt_state = new GetThreadState();
// We are setting the name of the thread GetThreadState
gt_state.setName("GetThreadState");
// Calling start() method with GetThreadState class
// object of Thread class/
gt_state.start();
// By using getName() method to return the name of this
// thread [GetThreadState]
System.out.println("The name of this thread is " + " " + gt_state.getName());
}
}

Output

输出量

E:\Programs>javac GetThreadState.java
E:\Programs>java GetThreadState
The name of this thread is  GetThreadState
The state of this thread is : RUNNABLE

翻译自: https://www.includehelp.com/java/thread-class-thread-state-getstate-method-with-example.aspx

this.getstate

this.getstate_Java线程类Thread.State getState()方法(带示例)相关推荐

  1. setname_Python线程类| setName()方法与示例

    setname Python Thread.setName()方法 (Python Thread.setName() Method) Thread.setName() method is an inb ...

  2. enumerate_Java Thread类的static int enumerate(Thread [] th)方法与示例

    enumerate 线程类static int枚举(Thread [] th) (Thread Class static int enumerate(Thread[] th)) This method ...

  3. Delphi中的线程类Thread

    原文:http://www.heibai.net/article/info/info.php?infoid=22594 Delphi中有一个线程类TThread是用来实现多线程编程的,这个绝大多数De ...

  4. getmethods_Java类类getMethods()方法及示例

    getmethods 类的类getMethods()方法 (Class class getMethods() method) getMethods() method is available in j ...

  5. python set |_Python事件类| set()方法与示例

    python set | Python Event.set()方法 (Python Event.set() Method) set() is an inbuilt method of the Even ...

  6. python 示例_Python条件类| release()方法与示例

    python 示例 Python Condition.release()方法 (Python Condition.release() Method) release() is an inbuilt m ...

  7. python 计时方法_Python计时器类| cancel()方法与示例

    python 计时方法 Python Timer.cancel()方法 (Python Timer.cancel() Method) cancel() is an inbuilt method of ...

  8. python 线程模块_Python线程模块| main_thread()方法与示例

    python 线程模块 Python threading.main_thread()方法 (Python threading.main_thread() Method) main_thread() i ...

  9. 【Groovy】闭包 Closure ( 闭包调用 与 call 方法关联 | 接口中定义 call() 方法 | 类中定义 call() 方法 | 代码示例 )

    文章目录 总结 一.接口中定义 call() 方法 二.类中定义 call() 方法 三.完整代码示例 总结 在 实例对象后使用 " () " 括号符号 , 表示调用该实例对象的 ...

最新文章

  1. Java使用字节码和汇编语言同步分析volatile,synchronized的底层实现
  2. 企业级区块链现状研究报告:小企业的投资总额是大企业的28倍
  3. 柳进军 | 城市大脑的逻辑模型
  4. VC 下 64bit 整数的显示和读取格式化字串
  5. java hbase 批量查询数据_HBase根据Rowkey批量查询数据JAVA API(一次查多条,返回多个记录)...
  6. 深入浅出深度学习(二)分类器
  7. python实现ai聊天机器人_AI人工智能Python实现简单人机对话:你好,人类!
  8. ctrl z推出查看文本怎么结束_最实用的10个电脑常用快捷键!Ctrl+Z的鬼才反向了解一下!...
  9. 05 库的简单操作
  10. centos ping 路由_centos服务器怎么ping 命令
  11. 2.三种前端跨域的解决方法
  12. CAS单点登录及处理流程介绍(一)
  13. word中公式和文字不在一条水平线上
  14. 桌面版 Linux 为什么打不过 Window?Linus 现身说法
  15. java catch中throw_Java的catch块中throw e和throw new Exception(e)有什么区别?
  16. Android videoView闪屏
  17. 【软考软件评测师】第五章节 安全测试测试方法
  18. 【图解数据结构】排序全面总结(一)
  19. python基础一 day56
  20. STM32CubeIDE HAL库DMA方式驱动MPU925X(1)

热门文章

  1. postscript打印机什么意思_涨知识|你不知道的关于打印机的打印过程和打印机驱动的那些事...
  2. java成员内部类_Java中的内部类(二)成员内部类
  3. 关于python语言和人工智能下哪个说法不正确_“在资源管理器”窗口中,文件夹图标左侧有“...
  4. mysql 副本 同步_副本机制与副本同步
  5. Java解决空引用_Java 匠人手法 - 优雅的处理空值
  6. JDK源码解析之java.util.Iterator和java.lang.Iterable
  7. golang代理转发基础
  8. DNS服务(4)Slave DNS及高级特性
  9. MyBatis-进阶2
  10. Cell.reuseIdentifier 指什么