知道美河 | 上传资料 | VIP申请 | 精品课程 | 资料搜索 | 问题反馈 | 会员手册 | 积分消费 | 积分充值 | 帐号保护
美河学习学习在线赞助VIP

美河学习在线(主站) eimhe.com

 找回密码
 建立账号
查看: 5945|回复: 1

[分享] 进程通信

[复制链接]
发表于 2007-8-4 11:29:22 | 显示全部楼层 |阅读模式
import java.io.*;
import java.util.*;
        class TestThreadFile implements Runnable {
         public void run(){
                //Date date=new Date();
                File file1=new File("F:\\xie1.txt");
                File file2=new File("F:\\xie2.txt");
                Long time1=file1.lastModified();
                Long time2=file2.lastModified();
                while(true){
                if(!(file1.exists())){
                        System.out.println("no File1");
                }
                if(!(file2.exists())){
                        System.out.println("no File2");
                }
                        try {
                                Thread.sleep(1000);
                        } catch (InterruptedException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        if(file1.lastModified()>time1||file2.lastModified()>time2){
                                System.out.println("change");
                        }
                        try {
                                Thread.sleep(1000);
                        } catch (InterruptedException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        if(file1.lastModified()<=time1||file2.lastModified()<=time2){
                                System.out.println("no changed");
        }}}}
public class TestThread extends Thread{
        public static void main(String[] args) {
                // TODO Auto-generated method stub
                TestThreadFile ft=new TestThreadFile();
                Thread thread1=new Thread(ft);
                Thread thread2=new Thread(ft);
                thread1.start();
                thread2.start();
}}
发表于 2009-4-5 17:46:15 | 显示全部楼层
您需要登录后才可以回帖 登录 | 建立账号

本版积分规则

 
QQ在线咨询

QQ|小黑屋|手机版|Archiver|美河学习在线 ( 浙网备33020302000026号 )

GMT+8, 2025-5-2 17:31

Powered by Discuz!

© 2001-2025 eimhe.com.

快速回复 返回顶部 返回列表