package printok;
import java.util.Scanner;
public class Control extends Thread{
public void run()
{
while(1==1)
{
Print ctl=new Print();
Scanner input=new Scanner(System.in);
int j=ctl.i=input.nextInt();
if(2==j)
break;
}
}
}
package printok;
public class Print extends Thread{
public static int i=0;
public void run()
{
while(1==1)
{
while(i==1)
{
System.out.println("ok");
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
while(1==1)
{
if(i==1||i==2)
break;
}
if(2==i)
{
System.out.println("程序结束");
break;
}
}
}
}
package printok;
public class start {
public static void main(String[] arg)
{
System.out.println("输入1开始打印ok,输入0暂停,输入2结束");
Thread cc=new Control();
Thread pp=new Print();
pp.start();
cc.start();
}
}
这个是java里的三个类,我测试过了,可以完成
谁写个C的学习下。。。