JAVA在语言级支持多线程

进程:任务

任务并发执行是一个宏观概念,微观上是串行的。

进程的调度是有OS负责的(有的系统为独占式,有的系统为共享式,根据重要性,进程有优先级)。

由OS将时间分为若干个时间片。

JAVA在语言级支持多线程。

分配时间的仍然是OS。

 1 package TomTexts;
 2 
 3 public class TomTexts_21 {
 4     public static void main(String args[])
 5     {
 6     int data1[]={2,4,6,8,10,12};
 7     int data2[]={1,0,2,4,3};
 8     try
 9     {
10     for(int i=0;i<data1.length;i++) {
11     try{
12     System.out.println(data1[i]+ "/"+data2[i]+ "is"+data1[i]/data2[i]);
13     }
14     catch(ArithmeticException e)
15     {
16     System.out.println("不能被零除!");
17     }
18     }
19     }
20     catch(ArrayIndexOutOfBoundsException e)
21     {
22     System.out.println("程序被终止!");
23     }
24     }
25 
26 }

猜你喜欢

转载自www.cnblogs.com/borter/p/9424953.html