您的位置:首页 > 其它

线程操作

2015-12-29 17:25 344 查看
1.第一种方式

public static void convertFlv(final String sourceFile,

final String tagetFile, final String kbps, final String ffmpegHomePath)

throws Exception {

Thread thread = new Thread(new Runnable() {

@Override

public void run() {

try {

StringBuffer command = new StringBuffer();

Process process = Runtime.getRuntime().exec(

command.toString());

int i = process.waitFor();

if (i == 0) {

/*

* Msg msg = smbPut(tagetFile); if(!msg.isB()){ throw

* new Exception(msg.getDesc()); }

*/

}

} catch (Exception e) {

e.printStackTrace();

}

}

});

thread.start();

}

2.第二中方式 synchronized

public String login(@QueryParam("ticket")String ticket) {

try{



boolean isRepeatRequest=false;

synchronized (Constants.TICKET_MAP) {

}else{

Constants.TICKET_MAP.put(ticket,System.currentTimeMillis());

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: