🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #24873

Re: �߳���ʲ�᣿

#24873
From: Lucky Lee
Date: Tue, 02 Dec 1997 00:00
106 lines
2182 bytes
�ϻ� Ji Hong ˵��...
>  
>       1�����߳����̵���� ������Լ������. 
>       2- - �̵߳ĺô� 
>       3������̾��� 
>        
>              I am looking forward you answer ,maybe we can discuss  
>  them together. 
>          thank you . 
>  helen 
 
������һ������:
    ���������߳�,ÿ������һ�����һ������ʱ,�͹���.
,������һ���̼߳���,���һ����ʾ.

class primeThread implements Runnable
{
 public void run()
 { 
  int number=3;
  int mod=0;
  boolean flag=true;
  while (true)  
  {
   loop:
   for (int i=2;i<number;i++)
   { 
    if ((mod=number%i)==0)
    {
     flag=false;
     break loop;
    }
   }
  if (flag)
  {
   System.out.println(number);
   flag=true;
  try  
  {
   Thread.sleep(5);
  }
  catch(InterruptedException e)
  {
   return;
  }
  }
  number++;
  flag=true; 
}
}
}

class runPrimes
{
 public static void main(String args[])
 {
  primeThread getPrimes=new primeThread();
  Thread myThread=new Thread(getPrimes);
  myThread.start();
  while (myThread.isAlive())
   {
   System.out.println("Counting the prime number...\n");
   try
   {
    Thread.sleep(5);
   }
   catch(InterruptedException e)
   {
    return;
   }
}
}
}

ִ�н��:
$ java runPrimes
Counting the prime number...

3
Counting the prime number...

5
Counting the prime number...

7
Counting the prime number...

11
Counting the prime number...

13
Counting the prime number...

17
Counting the prime number...

19
Counting the prime number...
....
,.,,
,,,

 �ֿ�
--
 * Origin: NJU PowerBBS �� <mail.nju.edu.cn>
Technical Details
Message-ID: <oxckii@mail.nju.edu.cn>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB
X-Google-Thread: f6cb0,2e76fe5d6bbae06e,start
X-Google-Attributes: gidf6cb0,public
From: Lucky_Lee.pbbs@mail.nju.edu.cn (Lucky Lee)
Subject: Re: �߳���ʲ�᣿
Date: 1997/12/02
Message-ID: <oxckii@mail.nju.edu.cn>
X-Deja-AN: 294874498
Organization: PowerBBS NJU Station
Newsgroups: cn.bbs.comp.lang.java