多线程
Posted My_blog_s
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多线程相关的知识,希望对你有一定的参考价值。
package com.jyc.filter;
import java.io.File;
import java.io.FileFilter;
import com.jyc.runnable.Runner1;
public class Test implements FileFilter{
@Override
public boolean accept(File pathname) {
String filename = pathname.getName().toLowerCase();
//System.out.println("-- "+pathname.getName());
if(filename.endsWith(".ctl")){
return true;
}else{
return false;
}
}
/*
* C:\sqlldr\a.ctl
C:\sqlldr\b.ctl
C:\sqlldr\c.ctl
C:\sqlldr\d.ctl
C:\sqlldr\e.ctl
C:\sqlldr\f.ctl
C:\sqlldr\g.ctl
C:\sqlldr\h.ctl
*/
public static void main(String[] args) {
File file = new File("C:\\sqlldr");
File[] files = file.listFiles(new Test());
for(File f : files){
System.out.println(f.getPath());
//new Thread(new Runner1(f.getPath())).start();
}
}
}
package com.jyc.runnable;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
public class Runner1 implements Runnable {
private String str;
public Runner1(String str) {
this.str = str;
}
@Override
public void run() {
//System.out.println(" = "+str); d.ctl
String cmd = "d:/db/oracle/product/10.2.0/db_2/bin/sqlldr userid=jyc/[email protected] control=" +
//"C:/mycontrl.ctl"
str
+" bad=c:/bad.txt";
try {
Process ldr = Runtime.getRuntime().exec(cmd);
InputStream stderr = ldr.getInputStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null)
System.out.println("*** " + line);
stderr.close();
isr.close();
br.close();
try {
ldr.waitFor();
} catch (Exception e) {
System.out.println("process function:loader wait for != 0");
}
} catch (Exception ex) {
System.out.println("process function:loader execute exception"
+ ex.toString());
}
}
}
以上是关于多线程的主要内容,如果未能解决你的问题,请参考以下文章