We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
int a = sheepList.size() - 1; for(int i=sheepList.size() - 1 ; i >= a - 3 ; i --){ sheepList.remove(i); } System.out.println(sheepList);
File fe = new File("b://leihous"); try{ if(!fe.exists()){ fe.mkdir(); } FileOutputStream nu = null; File file = null; for(int i = 1;i <= 10;i++){ file = new File(fe,"HelloWorld"+i+".txt"); nu = new FileOutputStream(file); if(!file.exists()){ file.createNewFile(); } String str ="我真 "+i; byte[] b = str.getBytes(); nu.write(b); nu.flush(); nu.close(); } }catch(IOException e){ e.printStackTrace(); } } }
//thread是单继承,runnable可以多个线程同时处理同一个变量
private int ticket = 10; private String name; public MyThread(String name){ this.name =name; } public void run(){ for(int i =0;i<500;i++){ if(this.ticket>0){ System.out.println(this.name+"卖票---->"+(this.ticket--)); } } } } public static void main(String[] args) { MyThread mt1= new MyThread("一号窗口"); MyThread mt2= new MyThread("二号窗口"); MyThread mt3= new MyThread("三号窗口"); mt1.start(); mt2.start(); mt3.start(); }
}
private int ticket = 10; private String name; public MyThread(String name){ this.name =name; } public void run(){ for(int i =0;i<500;i++){ if(this.ticket>0){ System.out.println(this.name+"卖票---->"+(this.ticket--)); } } }
public static void main(String[] args) { MyThread mt1= new MyThread("一号窗口"); MyThread mt2= new MyThread("二号窗口"); MyThread mt3= new MyThread("三号窗口"); mt1.start(); mt2.start(); mt3.start(); } } private int ticket =10; private String name; public void run(){ for(int i =0;i<500;i++){ if(this.ticket>0){ System.out.println(Thread.currentThread().getName()+"卖票---->"+(this.ticket--)); } } } } public static void main(String[] args) { // TODO Auto-generated method stub //设计三个线程 MyThread1 mt = new MyThread1(); Thread t1 = new Thread(mt,"一号窗口"); Thread t2 = new Thread(mt,"二号窗口"); Thread t3 = new Thread(mt,"三号窗口"); //MyThread1 mt2 = new MyThread1(); //MyThread1 mt3 = new MyThread1(); t1.start(); t2.start(); t3.start(); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
删羊
创建文件
thread和runnable的区别
//thread是单继承,runnable可以多个线程同时处理同一个变量
}
}
The text was updated successfully, but these errors were encountered: