日期:2014-05-20 浏览次数:20695 次
package com.loyu; public final class Word2Swf { private static Word2Swf word2Swf = null;//= new Word2Swf(); private Word2Swf(){ } public static Word2Swf getInstance(){ if(word2Swf==null) word2Swf = new Word2Swf(); return word2Swf; } public synchronized String word2Swf(String root,String target){ Process process; try { process = Runtime.getRuntime().exec("D:\\FlashPaper2.2\\FlashPrinter.exe \"d:\\cccc.docx\" -o \"d:\\"+target+".swf\""); process.waitFor(); } catch (Exception e) { e.printStackTrace(); } return null; } }
package com.loyu.test; import java.io.IOException; import com.loyu.Word2Swf; public class Test { public static void main(String[] args) throws IOException { System.out.println(2222); new Thread(new Word2SwfThread("1"),"").start(); new Thread(new Word2SwfThread("2"),"").start(); new Thread(new Word2SwfThread("3"),"").start(); new Thread(new Word2SwfThread("4"),"").start(); new Thread(new Word2SwfThread("5"),"").start(); new Thread(new Word2SwfThread("6"),"").start(); System.out.println(3333); } } class Word2SwfThread implements Runnable{ private String name; public Word2SwfThread(String name){ this.name=name; } @Override public void run() { System.out.println(1); // try { Word2Swf.getInstance().word2Swf(null, name); // } catch (Exception e) { // e.printStackTrace(); // } } }
<?xml version="1.0" encoding="gbk" ?> <project name="HelloWorld" default="run" basedir="."> <property name="src" value="src" /> <property name="dest" value="classes" /> <property name="hello_jar" value="hello.jar" /> <target name="init"> <echo message="生成编译目录"/> <mkdir dir="${dest}" /> </target> <target name="compile" depends="init"> <echo message="开始编译"/> <javac includeantruntime="on" srcdir="${src}" destdir="${dest}" /> </target> <target name="jar" depends="compile"> <echo message="打jar包"/> <jar jarfile="${hello_jar}" basedir="${dest}" /> </target> <target name="run" depends="jar"> <echo message="执行程序"/> <java classname="com.loyu.test.Test" classpath="${hello_jar}" /> </target> <target name="clean"> <delete dir="${dest}" /> <delete file="${hello_jar}" /> </target> <target name="rerun" depends="clean, run"> <ant target="clean" /> <ant target="run" /> </target> </project>