题目内容

分析程序,写出结果class MyThread1 extends Thread{private String name;public MyThread1(String name){this.name=name;}@Overridepublic void run() {for(int i=0;i<10;i++){System.out.println(name+i);}}}class MyThread2 implements Runnable{private String name;public MyThread2(String name){this.name=name;}@Overridepublic void run() {for(int i=0;i<10;i++){System.out.println(name+i);}}}class MyThread3 implements Runnable{private int ticket=5;@Overridepublic void run() {if(ticket>0){System.out.println("卖票:ticket="+ticket--);}}}class MyThread4 implements Runnable{@Overridepublic void run() {for(int i=0;i<3;i++){System.out.println(Thread.currentThread().getName()+"运行,i="+i);}}}class MyThread5 implements Runnable{private String name;private int time;public MyThread5(String name,int time){this.name=name;this.time=time;}@Overridepublic void run() {try {Thread.sleep(this.time);} catch (InterruptedException e) {e.printStackTrace();}System.out.println(this.name+"线程,休眠"+this.time+"毫秒");}}class MyThread6 implements Runnable{private int ticket=110;@Overridepublic void run() {for(int i=0;i<200;i++){synchronized(this){if(ticket>0){try {Thread.sleep(100);} catch (InterruptedException e) {e.printStackTrace();}System.out.println(Thread.currentThread().getName()+"卖票:ticket="+ticket--);}}}}}public class ThreadDemo1 {public static void main(String[] args) {MyThread6 mt=new MyThread6();Thread t1=new Thread(mt,"A");Thread t2=new Thread(mt,"B");Thread t3=new Thread(mt,"C");Thread t4=new Thread(mt,"D");Thread t5=new Thread(mt,"E");t1.start();t2.start();t3.start();t4.start();t5.start();}}

查看答案
更多问题

分析程序,写出结果class Info{private String name="张三";private boolean flag=false;public synchronized void set(String name){if(!flag){try {super.wait();} catch (InterruptedException e) {e.printStackTrace();}}this.setName(name);try {Thread.sleep(300);} catch (InterruptedException e) {e.printStackTrace();}flag=false;super.notify();}public synchronized void get(){if(flag){try {super.wait();} catch (InterruptedException e) {e.printStackTrace();}}try {Thread.sleep(300);} catch (InterruptedException e) {e.printStackTrace();}System.out.println(this.getName()+"-->" );flag=true;super.notify();}public String getName() {return name;}public void setName(String name) {this.name = name;}}class Producer implements Runnable{private Info info=null;public Producer(Info info){this.info=info;}@Overridepublic void run() {boolean flag=false;for(int i=0;i<20;i++){if(flag){this.info.set("张三");flag=false;}else{this.info.set("李四");flag=true;}}}}class Consumer implements Runnable{private Info info=null;public Consumer(Info info){this.info=info;}@Overridepublic void run() {for(int i=0;i<20;i++){try {Thread.sleep(100);} catch (InterruptedException e) {e.printStackTrace();}this.info.get();}}}public class ThreadDemo2 {public static void main(String[] args) {Info i=new Info();Producer pro=new Producer(i);Consumer con=new Consumer(i);new Thread(pro).start();new Thread(con).start();}}

制定幼儿语言教育目标的依据是什么?

幼儿语言教育目标是怎样划分结构的?

学前儿童语言教育的内容有哪些?

答案查题题库