线程操作
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());
}
}
}
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());
}
}
}
相关文章推荐
- http协议
- Computer vision
- POJ训练计划2418_Hardwood Species(Trie树)
- 开发工具
- 网络编程学习笔记--1.socket可读可写条件
- DWR3使用
- 神经网络中的BPTT算法简单介绍
- 判断两个UIColor的颜色值是否相等
- Android之JAVASe基础篇-面向对象-对象数组(三)
- php取数组随机数
- TexturePacker非常棒的游戏资源图像处理工具
- TCP慢启动、拥塞避免、快速重传、快速回复
- NAS环境中的备份:服务器、NDMP协议
- notebook 的使用
- Python 使用 xlrd 读取 Excel格式文件
- UIAlertView使用
- HTML5的新特性
- CoreGraphics --- 翻转坐标系
- Ios - 计算Label文字中字体的frame - 实用代码
- Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar