public class ex2_7 extends Applet public Color color2_7 = Color. black; private iht n2_7 = 3; public myPrime thPrime2_7; public void init( ) thPrime2_7 = new myPrime(this); thPrime2_7, start( );
public void paint(Graphics g) g, setColor( color2_7 ); g. drawString( (1) ,50,50);
public int getlnt( ) return n2_7;
public void setlnt (int i) n2_7 = i;
class myPrime extends Thread I ex2_7 obj2_7; myPrime (ex2_7 o) this. obj2_7 = o;
public boolean isPrime(int n) boolean bPrime = true; iht i =2; if( (2) ) return false; while( i < n - ]&&bPrime) if( (3) ) bPrime = false; i++;
return bPrime;
public void run( ) int i; for (i = 3; (4) ;i++) if (isPrime(i) ) obj2 _7, color2_7 = Color, gray; else obj2_7, color2_7 = Color. green; (5) ; obj2_7, repaint( ); try sleep(S00); catch (InterruptedException ie)
ex2_7, html < HTML > < HEAD > <TITLE > ex2_7 </TITLE > </HEAD > < BODY > <appletcode =" ex2_, class" width =800 height =400 > </applet > </BODY > </HTML >