Problem with threads and camera.

Hi everybody!

I've a problem with taking snapshot.

I would like to display a loading screen after it take snapshot ( sometimes i

have to wait few seconds after i took snapshot. Propably photo is being taken in time where i have to wait).

I was trying to use threads but i didn't succeed.

I made this code:

display.setCurrent(perform);

new Thread(new Runnable(){

publicvoid run(){

while((!performing.isShown()) && (backgroundCamera.isShown())){

Thread.yield();

}

notifyAll();

}

}).start();

new Thread(new Runnable(){

publicvoid run(){

try{

this.wait();

}catch(Exception e){

exceptionHandler(e);

}

photo = camera.snapshot();

display.setCurrent(displayPhoto);

}

}).start();

This code is sometimes showing performing screen but sometimes no.

I don't know why. In my opinion performing.isShown() method isn't working correctly.

Does anyone have some idea how to use threads here?

[1797 byte] By [Bodzioa] at [2007-11-27 6:01:54]
# 1

Hi,

I've finally managed to work this fine.

The code:

Object o = new Object();

display.setCurrent(perform);

new Thread(new Runnable(){

public void run() {

while(!performing.isShown()){

Thread.yield();

}

synchronized(o) {

o.notify();

}

}

}).start();

new Thread(new Runnable(){

public void run() {

try {

synchronized(o) {

o.wait(1);

}

} catch(Exception e) {

exceptionHandler(e);

}

photo = camera.snapshot();

display.setCurrent(displayPhoto);

}

}).start();

Bodzioa at 2007-7-12 16:42:28 > top of Java-index,Java Mobility Forums,Java ME Technologies...