I'm creating a Java Slideshow using some 2DTransitions I found on the net. Everything work smoothly, but I come across a problem why trying to execute code after the Slideshow has been rendered. I thought Java threads are used to isolate processes, for instance I have a similar setup with an infinite while loop, and a thread solved that problem. Here it isn't working and I cant figure out why. In the code below I get to the first outputs, but it hangs on thread.run and never prints the last output.
Any ideas why?
Here is the relevant code:
System.out.println("Slideshow init");
Thread thread = new Thread(new Runnable() {
//TODO SLIDESHOW PROBLEM RIGHT HERE
public void run(){
int i=0;
while(keepgoing){
if(i==images.size()-1){
transit(images.get(images.size()-1),images.get(0));
i=0;
}
else
transit(images.get(i),images.get(i+1));
i++;
}
}
});
System.out.println("Thread created");
thread.run();
System.out.println("Thread started");`
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…