本帖最后由 郭阳 于 2012-9-26 19:52 编辑
- import java.io.*;
- class IODemo
- {
- public static void main(String[] args)
- {
- BugThread bt=new BugThread();
- Thread t1=new Thread (bt);
- Thread t2=new Thread (bt);
- Thread t3=new Thread (bt);
- Thread t4=new Thread (bt);
- Thread t5=new Thread (bt);
- t1.start();
- t2.start();
- t3.start();
- t4.start();
- t5.start();
- }
- }
- class BugThread implements Runnable
- {
- FileWriter fw=null;
- try
- {
- fw=new FileWriter("Demo.txt");
- }
- catch (Exception e){}
- public void run()
- {
- for (;; )
- {
- try
- {
- fw.write("abcdefg");
- fw.flush();
- }
- catch(Exception e){}
- }
- }
- }
复制代码
|