Hello everybody,
I have some trouble with threads. The thing is the following: I have
my main Activity, which is doing some OpenGL and should be doing it at
all time. In parallel to that I start another activity, which is
waiting for some network traffic, once there arrives sth a variable
should be changed.

public class OpenGLRenderer extends GLSurfaceView implements  Rend{
    boolean test = false;
        public OpenGLRenderer(Context context) {
                super(context);
                Thread t = new Thread(){
                public void run(){
                        try{
                                ServerSocket ss = new ServerSocket(7070);
                                while(true){
                                        test = test(ss);
                                        handler.post(update);
                                }
                }catch(Exception e){
                        e.printStackTrace();
                }

                }
        };
        t.start();
   }
    public void onDrawFrame(GL10 gl) {
                if(test){
                        Log.d("catch", "test==true");
                }
    }

      final Runnable update = new Runnable() {
                @Override
                public void run() {
                        Log.d("catch", "test: "+(test));
    }

          private boolean test(ServerSocket ss){
                try{
                        Log.d("com", "wait for incomming connection.....");
                        while(true){
                                try {
                                        ss.setSoTimeout(500);
                                        Socket s = ss.accept();
                                        ObjectInputStream ois = new
ObjectInputStream(s.getInputStream());
                                        String in = new 
String((byte[])ois.readObject());
                                        //do something
                                        return true;
                                }catch(SocketTimeoutException e){}
                        }
                }catch(Exception e){
                        e.printStackTrace();
                }
        return false;
        }
}

So the thing now is that "test" is true in the update-Runnable, but it
is still false when I call it in onDrawFrame.
Why is that the case, I am getting really desperate, can anybody help
please!?!?

Thanks a lot
regards

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to