日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java中有ClockPane类吗_Java程序设计教程 冶金工业出版社第9章

發布時間:2025/3/12 java 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java中有ClockPane类吗_Java程序设计教程 冶金工业出版社第9章 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

第9章多線程與Applet

//例程9-1:Pi.java

/*演示采用多線程技術計算圓周率*/

public class Pi{

public static void main(String[] args){

PiCaculator pc = new PiCaculator();

Thread t = new Thread(pc);

t.start();

try{

Thread.sleep (10000); //休眠,等待可能出現的異常情況

t.interrupt ();

}catch(InterruptedException e){

e.printStackTrace();

}

}

}

class PiCaculator implements Runnable{

private double latestPiEstimate;

public void run(){

try{

System.out.print ("Math.PI = "+ Math.PI + "\t" );

calPi(0.00001);

System.out.println ("the latest PI = "+http://www.doczj.com/doc/c5af6d3410661ed9ad51f381.htmltestPiEstimate );

}catch(InterruptedException e){

System.out.println("The caculator is Interrupted.");

}

}

/**用于計算圓周率的方法,accuracy為計算精度*/

private void calPi(double accuracy) throws InterruptedException

{

http://www.doczj.com/doc/c5af6d3410661ed9ad51f381.htmltestPiEstimate =0.0;

long iteration = 0;

int sign = -1;

//按給定精度計算圓周率

while(Math.abs (http://www.doczj.com/doc/c5af6d3410661ed9ad51f381.htmltestPiEstimate)>accuracy){

if(Thread.interrupted ())

throw new InterruptedException();

總結

以上是生活随笔為你收集整理的java中有ClockPane类吗_Java程序设计教程 冶金工业出版社第9章的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。