this.getstate_Java線程類Thread.State getState()方法(帶示例)

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

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/542473.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/542473.shtml
英文地址,請注明出處:http://en.pswp.cn/news/542473.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Java資源大全中文版(Awesome最新版)

來源:http://www.cnblogs.com/best/p/5876559.html 目錄 業務流程管理套件字節碼操作集群管理代碼分析編譯器生成工具構建工具外部配置工具約束滿足問題求解程序持續集成CSV解析數據庫數據結構時間日期工具庫依賴注入開發流程增強工具分布式應用分布式數據庫發布文檔…

運用多種設計模式的綜合案例_SpreadJS 純前端表格控件應用案例:表格數據管理平臺...

由某科技公司研發的表格數據管理平臺,是一款面向業務和企業管理系統定制開發的應用平臺,包括類 Excel 設計器、PC應用端和移動應用端等應用模塊。該平臺具備強大的業務配置和集成開發能力,對于企業客戶的信息系統在管理模式、業務流程、表單界…

linux定位哪個進程出發重啟,定位Linux下定位進程被誰KILL

hezhaoaqiang2012-11-09 11:10可以請教你一個問題嗎?關于arm的交叉編譯。我是按照:http://blog.chinaunix.net/uid-27003388-id-3276139.html 去做的,但是走到 四、建立初始編譯器(bootstrap gcc)下面的make install 它提示如下:m…

Java Integer類numberOfLeadingZeros()方法的示例

整數類numberOfLeadingZeros()方法 (Integer class numberOfLeadingZeros() method) numberOfLeadingZeros() method is available in java.lang package. 在java.lang包中提供了numberOfLeadingZeros()方法 。 numberOfLeadingZeros() method is used to returns the number o…

VS中C++ 項目重命名

應該都有過這樣的經歷,在Visual studio中創建解決方案,添加幾個項目進去,然后開始愉快的敲代碼...。寫代碼正歡的時候,卻總是感覺那里有些不舒服,一細看,這項目名稱取的真心挫,修改個吧。直接右…

Java GregorianCalendar getActualMinimum()方法與示例

GregorianCalendar類getActualMinimum()方法 (GregorianCalendar Class getActualMinimum() method) getActualMinimum() method is available in java.util package. getActualMinimum()方法在java.util包中可用。 getActualMinimum() method is used to get the actual minim…

axure9數據統計插件_WMDA:大數據技術棧的綜合實踐

一、概述WMDA是58自主開發的用戶行為分析產品,同時也是一款支持無埋點的數據采集產品,只需要在第一次使用的時候加載一段SDK代碼,即可采集全量、實時的PC、M、APP三端以及小程序的用戶行為數據。同時,為了滿足用戶個性化的數據采集…

Java Collections unmodifiableCollection()方法與示例

集合類unmodifiableCollection()方法 (Collections Class unmodifiableCollection() method) unmodifiableCollection() method is available in java.util package. unmodifiableCollection()方法在java.util包中可用。 unmodifiableCollection() method is used to get an un…

openfoam安裝中出現allmake error_如何更新OpenFOAM的版本?

這是協作翻譯的第四章,翻譯完感覺挺有意思的,分享給大家一起看看。4.更新OpenFOAM版本4.1 版本管理OpenFOAM以兩種不同的方式分發。一種方式是使用Git倉庫下載的倉庫版本。倉庫版本的版本號由附加的x標記,例如 OpenFOAM2.1.x。該版本會經常更…

java 根據類名示例化類_Java類類的requiredAssertionStatus()方法和示例

java 根據類名示例化類類的類requiredAssertionStatus()方法 (Class class desiredAssertionStatus() method) desiredAssertionStatus() method is available in java.lang package. requiredAssertionStatus()方法在java.lang包中可用。 desiredAssertionStatus() method is …

python中計算排列組合的函數_Python實現的排列組合計算操作示例

本文實例講述了Python實現的排列組合計算操作。分享給大家供大家參考,具體如下:1. 調用 scipy 計算排列組合的具體數值>> from scipy.special import comb, perm>> perm(3, 2)6.0>> comb(3, 2)3.02. 調用 itertools 獲取排列組合的全部…

java日歷類add方法_Java日歷setMinimalDaysInFirstWeek()方法與示例

java日歷類add方法日歷類setMinimalDaysInFirstWeek()方法 (Calendar Class setMinimalDaysInFirstWeek() method) setMinimalDaysInFirstWeek() method is available in java.util package. setMinimalDaysInFirstWeek()方法在java.util包中可用。 setMinimalDaysInFirstWeek(…

相同布局在不同手機上顯示不同_不懂響應式,不同尺寸屏幕下的頁面很難達到最佳效果...

讓用戶在不同設備和尺寸的屏幕下看的頁面顯示效果更佳,屏幕空間利用更高,操作體驗更統一,交互方式更符合習慣。本文主要圍繞什么是響應式,如何搭建響應系統,響應式網站解析 三個部分進行闡述,在項目中提前定…

Java ByteArrayInputStream markSupported()方法與示例

ByteArrayInputStream類markSupported()方法 (ByteArrayInputStream Class markSupported() method) markSupported() method is available in java.util package. markSupported()方法在java.util包中可用。 markSupported() method is used to check whether this ByteArrayI…

markdown 流程圖_測試了12款Markdown編輯器,推薦一個最好用的!

有很多喜歡寫博客的小伙伴問我,這個代碼筆記的格式怎么弄的簡潔又好看,雖然csdn里面有Markdown的書寫模式,但是我還是想推薦一款比較好用的寫筆記的編輯器 - Typora。相信很多小伙伴都在使用吧,這個一直是我最喜歡的 markdown 編輯…

小程序 || 語句_C ++條件語句| 查找輸出程序| 套裝2

小程序 || 語句Program 1: 程序1&#xff1a; #include <iostream>#include <stdio.h>using namespace std;int main(){int num 0;num printf("%d ", printf("%d ", printf("ABC")));if (num 2) {cout << "INDIA&quo…

python爬取天氣預報源代碼_python抓取天氣并分析 實例源碼

【實例簡介】Python代碼抓取獲取天氣預報信息源碼講解。這是一個用Python編寫抓取天氣預報的代碼示例&#xff0c;用python寫天氣查詢軟件程序很簡單。這段代碼可以獲取當地的天氣和、任意城市的天氣預報&#xff0c;原理是根據url找到網站截取相應的數據展現。python抓取廣州天…

Linux編譯程序源碼環境,Linux下對nodejs環境進行源碼編譯并部署云應用

Node 是一個讓 JavaScript 運行在服務端的開發平臺&#xff0c;它讓 JavaScript 成為與PHP、Python、Perl、Ruby 等服務端語言平起平坐的腳本語言。該環境安裝非常簡單&#xff0c;這里簡單記錄下linux(centos環境下)的源碼安裝&#xff0c;做個記錄。平臺&#xff1a;centos 6…

endswith方法_帶有示例JavaScript字符串endsWith()方法

endswith方法字符串endsWith()方法 (String endsWith() Method) endsWith() method is a string method in JavaScript, it is used to check whether a string ends with a specified substring or not. EndsWith()方法是JavaScript中的字符串方法&#xff0c;用于檢查字符串是…

mysql多行合并成一行_數據文件合并與拆分

在數據處理業務中&#xff0c;經常要把文件結構相同或近似相同的數據文件合并成一個文件&#xff0c;或者將一個比較大的數據文件拆分成小的數據文件。本文將介紹文本文件和 Excel 文件合并及拆分會遇到的幾種情況&#xff0c;并提供用 esProc SPL 編寫的代碼示例。esProc 是專…