package com.abc.test;
import org.testng.annotations.BeforeClass;
public class ShortJob{
@BeforeClass(alwaysRun=true)
public void setUp() {
integrationUtil.pushVideoStream(); // this is a method in another class
try{
Thread.sleep(8000);
}catch(Exception e){
System.out.println("there are some errors");
}
System.out.println("this is the main thread");
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package com.abc.test;
public class IntegrationTestUtil {
public void pushVideoStream(){
ffmpegTools = "D:\\ffmpeg.exe ";
List<String> command = new ArrayList<String>();
command.add(ffmpegTools);
command.add("-re");
command.add("-i");
command.add(resource);
command.add("-codec");
command.add("copy");
command.add("-f");
command.add("flv");
command.add("rtmp://107.169.18.41:1935/live_hls/bbc");
try{
ProcessBuilder builder = new ProcessBuilder();
builder.command(command);
builder.start();
logger.info(" push stream to nts3.photo.163.org successfully");
}catch(Exception e){
System.out.println("there occurs an error in builder");
}
}
}
I want to start a new thread in setup() method which is annotated with @BeforeClass in ShortJob, and then I want to let the main thread sleep for some time while the new thread is running, but the result is when main thread sleep, the new thread also sleeps, why it occurs?
Aucun commentaire:
Enregistrer un commentaire