线程代码如下:
如果让222在111和333之间打印出来?谢谢
public class SAaa
{
public static void main(String[] args)
{
ForPrint FP = new ForPrint(0);
System.out.println("111");
FP.start();
System.out.println("333");
}}和import java.io.*;
public class ForPrint extends Thread
{
int i;
public ForPrint(int I)
{
i= I;
}
public void run()
{
try
{
for(int c = 1 ;c < 4 ; c++)
{
System.out.print("2");
Thread.sleep(i);
}
System.out.println();
}
catch(InterruptedException e)
{
return;
}
}
/* public static void main(String[] args)
{
new ForPrint(1200).start();
}*/
}
如果让222在111和333之间打印出来?谢谢
public class SAaa
{
public static void main(String[] args)
{
ForPrint FP = new ForPrint(0);
System.out.println("111");
FP.start();
System.out.println("333");
}}和import java.io.*;
public class ForPrint extends Thread
{
int i;
public ForPrint(int I)
{
i= I;
}
public void run()
{
try
{
for(int c = 1 ;c < 4 ; c++)
{
System.out.print("2");
Thread.sleep(i);
}
System.out.println();
}
catch(InterruptedException e)
{
return;
}
}
/* public static void main(String[] args)
{
new ForPrint(1200).start();
}*/
}
while(true){
if(标识改变){
break;
}
Thread.sleep(100);
}