bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

Java守護(hù)線程用法實(shí)例分析

本文實(shí)例講述了Java守護(hù)線程用法。分享給大家供大家參考,具體如下:

為九臺(tái)等地區(qū)用戶提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及九臺(tái)網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為網(wǎng)站設(shè)計(jì)、做網(wǎng)站、九臺(tái)網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!

一 點(diǎn)睛

針對(duì)守護(hù)線程,只要有一個(gè)用戶線程在執(zhí)行,這個(gè)進(jìn)程就不會(huì)結(jié)束。

當(dāng)線程中只剩下守護(hù)線程時(shí),JVM會(huì)自動(dòng)退出,反之,如果還有其他任何用戶線程存在,JVM都不會(huì)退出。

二 代碼

public class ThreadDaemon
{
  public static void main( String args[] )
  {
   ThreadTest t = new ThreadTest();
   Thread tt = new Thread( t );
   tt.setDaemon( true ); // 設(shè)置后臺(tái)運(yùn)行
   tt.start( );
   try
   { // 睡眠1毫秒,避免可能出現(xiàn)的沒(méi)有輸出的現(xiàn)象
     Thread.sleep( 1 );
   }
   catch( InterruptedException e )
   {
     e.printStackTrace();
   }
  }
}
class ThreadTest implements Runnable
{
  public void run()
  {
   for( int i = 0; true; ++i )
   {
     System.out.println( i + " " + Thread.currentThread().getName()
        + " is running." );
   }
  }
}

三 運(yùn)行

0  Thread-0 is running.
1  Thread-0 is running.
2  Thread-0 is running.
3  Thread-0 is running.
4  Thread-0 is running.
5  Thread-0 is running.
6  Thread-0 is running.
7  Thread-0 is running.
8  Thread-0 is running.
9  Thread-0 is running.
10  Thread-0 is running.
11  Thread-0 is running.
12  Thread-0 is running.
13  Thread-0 is running.
14  Thread-0 is running.
15  Thread-0 is running.
16  Thread-0 is running.
17  Thread-0 is running.
18  Thread-0 is running.
19  Thread-0 is running.
20  Thread-0 is running.
21  Thread-0 is running.
22  Thread-0 is running.
23  Thread-0 is running.
24  Thread-0 is running.
25  Thread-0 is running.
26  Thread-0 is running.
27  Thread-0 is running.
28  Thread-0 is running.

更多java相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Java進(jìn)程與線程操作技巧總結(jié)》、《Java數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Java操作DOM節(jié)點(diǎn)技巧總結(jié)》、《Java文件與目錄操作技巧匯總》和《Java緩存操作技巧匯總》

希望本文所述對(duì)大家java程序設(shè)計(jì)有所幫助。

名稱欄目:Java守護(hù)線程用法實(shí)例分析
URL鏈接:http://vcdvsql.cn/article0/pcdhio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化小程序開(kāi)發(fā)外貿(mào)網(wǎng)站建設(shè)企業(yè)建站網(wǎng)站制作網(wǎng)頁(yè)設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站優(yōu)化排名