Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JAVAµ÷ÓÃÍⲿ½ø³Ì×î¼Ñʵ¼ù°æ×é¼þ

package com.allywll.core.exec.base;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeoutException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import com.allywll.core.util.PeriodicalTask;
import com.gzit.core.util.ArrayUtil;
/**
* ¶ÔÒ»¸öÍⲿ½ø³ÌÖ´Ðйý³ÌµÄ³éÏó
*
* @author gzit team
*
*/
public class ProcessorExecutor implements CmdExecutor {
private static Logger logger = Logger.getLogger("PROCESSOR");
// ½ø³ÌµÄÖ´Ðз¾¶
protected String workingDirectory;
// ½ø³ÌÊä³öµÄ×Ö·û±àÂë
// ĬÈÏʹÓÃƽ̨µÄ×Ö·û±àÂë
private String outputEncoding = Charset.defaultCharset().name();
// ½ø³ÌµÄÖ´ÐÐÃüÁî
protected String cmd;
// ½ø³ÌµÄÖ´ÐвÎÊý
protected String[] args;
// ½ø³ÌÖ´Ðеij¬Ê±Ê±¼ä £ºµ¥Î»ÎªºÁÃ룬-1²»¿¼Âdz¬Ê±»úÖÆ£¬Óг¬Ê±µÄ»°½«Íⲿ½ø³Ìdestroyµô
protected long timeout = -1;
protected long beginTime;// ½ø³ÌÖ´ÐеĿªÊ¼Ê±¼ä
protected long endTime;// ½ø³ÌÖ´ÐеĽáÊøʱ¼ä
protected Process process; // µ±Ç°Ö´ÐеĽø³Ì
protected boolean blocking;// µ±Ç°Ö´ÐеĽø³ÌÊÇ·ñÕý´¦ÔÚ×èÈûÖ®ÖÐ
protected boolean flagTimeout;// ÊÇ·ñ·¢Éú³¬Ê±Òì³£
/**
*
* ½ø³ÌÖ´Ðйý³ÌµÄ¼à¿Ø(³¬Ê±ÒÔ¼°ÆäËüµÄ״̬¼ì²â)
*
*/
private static class ExecutorMonitor extends PeriodicalTask {
private Logger elogger = Logger.getLogger("PROCESSOR");
private List<ProcessorExecutor> executors = new LinkedList<ProcessorExecutor>();
public ExecutorMonitor(int period) {
super(period);
}
public void reg(ProcessorExecutor exec) {
this.executors.add(exec);
}
public synchronized void deReg(ProcessorExecutor exec) {
if (exec != null) {
this.executors.remove(exec);
}
}
@Override
protected void doWork() throws Exception


Ïà¹ØÎĵµ£º

Java ¶àÏ̱߳à³ÌÖ®ÆߣºËÀËø£¨¸½Ô´´úÂ룩

Java ¶àÏ̱߳à³ÌÖ®ÆߣºËÀËø£¨¸½Ô´´úÂ룩
Ô´´úÂëÏÂÔØ
        ¶àÏ̱߳à³ÌÖУ¬Ïß³ÌËÀËøÒ²ÊÇÒ»¸ö±È½ÏÓÐȤµÄÎÊÌ⡣Ȼ¶øËÀËø·¢ÉúµÄ¿ÉÄÜÐÔºÜС£¬ÕýÒòÈç´Ë£¬´ó¼Ò¿ÉÄܶԴ˲»ÊǺÜÊìϤ¡£µ«ÊÇËÀËø²¢²»ÊDz»ÖØÒª£¬ÒòΪËüȷȷʵʵ´æÔÚ×Å£¬Ëæʱ»á³öÏÖÔÚÎÒÃǵijÌÐòÖ®ÖС£ºÜ¶àÅóÓÑÃæÊÔµÄʱºò¶¼Óöµ½¹ýÕâ ......

javaÖжÔÏóµÄÐòÁл¯


ÐòÁл¯µÄ¹ý³Ì¾ÍÊǽ«¶ÔÏóдÈë×Ö½ÚÁ÷ºÍ´Ó×Ö½ÚÁ÷ÖжÁÈ¡¶ÔÏó¡£½«¶ÔÏó״̬ת»»³É×Ö½ÚÁ÷Ö®ºó£¬¿ÉÒÔÓÃjava.io°üÖеĸ÷ÖÖ×Ö½ÚÁ÷ÀཫÆä±£´æµ½ÎļþÖУ¬¿ÉÒÔͨ¹ý¹ÜµÀ»òÏ̶߳ÁÈ¡£¬»òͨ¹ýÍøÂçÁ¬½Ó½«¶ÔÏóÊý¾Ý·¢Ë͵½ÁíÒ»Ö÷»ú¡£¶ÔÏóÐòÁл¯¹¦Äܷdz£¼òµ¥¡¢Ç¿´ó£¬ÔÚRMI¡¢Socket¡¢JMS¡¢EJB¶¼ÓÐÓ¦Ó᣶ÔÏóÐòÁл¯ÎÊÌâÔÚÍøÂç±à³ÌÖв¢²»ÊÇ×¶¯ÈË ......

JavaÖеÄÄÚ²¿ÀàºÍÄäÃûÀà(ת)

[ÕªÒª]
ÌáÆðJavaÄÚ²¿ÀࣨInner
Class£©¿ÉÄܺܶàÈ˲»Ì«ÊìϤ£¬Êµ¼ÊÉÏÀàËƵĸÅÄîÔÚC++ÀïÒ²ÓУ¬ÄǾÍÊÇǶÌ×ÀࣨNested
Class£©£¬¹ØÓÚÕâÁ½ÕßµÄÇø±ðÓëÁªÏµ£¬ÔÚÏÂÎÄÖлáÓжԱȡ£
[¹Ø¼ü×Ö] Java
ÄÚ²¿Àà
ÄäÃûÀà

¡¡¡¡ÓÐÈË»áÎÊ£¬Èç¹ûÄÚ²¿ÀàÀïµÄÒ»¸ö³ÉÔ±±äÁ¿ÓëÍⲿÀàµÄÒ»¸ö³ÉÔ±±äÁ¿Í¬Ãû£¬Ò²¼´ÍⲿÀàµÄͬÃû³ÉÔ±±äÁ¿±»ÆÁ±ÎÁ ......

ÔËÐÐʱʵÏÖJavaµÄ¶à̬ÐÔ

     ÔËÐÐʱ¶à̬ÐÔÊÇÃæÏò¶ÔÏó³ÌÐòÉè¼Æ´úÂëÖØÓõÄÒ»¸ö×îÇ¿´ó»úÖÆ£¬¶¯Ì¬ÐԵĸÅÄîÒ²¿ÉÒÔ±»Ëµ³É“Ò»¸ö½Ó¿Ú£¬¶à¸ö·½·¨”¡£JavaʵÏÖÔËÐÐʱ¶à̬ÐԵĻù´¡ÊǶ¯Ì¬·½·¨µ÷¶È£¬ËüÊÇÒ»ÖÖÔÚÔËÐÐʱ¶ø²»ÊÇÔÚ±àÒëÆÚµ÷ÓÃÖØÔØ·½·¨µÄ»úÖÆ£¬ÏÂÃæ¾Í¼Ì³ÐºÍ½Ó¿ÚʵÏÖÁ½·½Ãæ̸̸javaÔËÐÐʱ¶à̬ÐÔµÄʵÏÖ¡£
¡¡¡¡Ò»¡¢Í¨¹ý ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ