ss.txt

来自「操作系统的部分实验源码 希望你们会喜欢 学操作系统必备的」· 文本 代码 · 共 45 行

TXT
45
字号

public class Thread_1 extends Thread
{
	public static int sum=0;
	public static int n=0;
	public static int m=0;
	public static int i=0;
	public static boolean pd=true;
	public int id;
	
	public Thread_1(int id)
	{
		this.id=id;
	}
	
	public synchronized void run()
	{
		for (;n<101;n++)
			sum=sum+n;
		for(;m<1000;m++)
		{
			for(i=2;i<m;i++)
				if(m%i==0)
					break;
			if(i==m)
				System.out.println("id is "+id+"\t number is "+m);
		}
		if(pd==true)
		{
			System.out.println("\nsum is "+Thread_1.sum);
			pd=false;
		}
	}
	
	public static void main(String args[])
	{
		Thread_1 t1=new Thread_1(1);
		Thread_1 t2=new Thread_1(2);
		//Thread_1 t3=new Thread_1(3);
		t1.start();
		t2.start();
		//t3.start();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?