Hi all,
Here's my oddity:
I have two emulators communicating via TCP.  Each emulator has two
threads - one running a server, and the other running a client.  Each
thread is in a loop, waiting until that thread gets a connection
(socket) with the other emulator.  Once a thread gets a connection, it
calls a synchronized method - doSomething().  Since each thread
(server and client) is vying for the same synchronized method, only
one thread is active at a given time. For instance, first Emulator1
will have an active server connected to client of Emulator2. Then when
this finishes, Emulator2 may be the server for Emulator1's client.
etc.

This all seems to work. Except, for....
when I force one emulator's server to exit its perpetual loop of
accepting inbound connections, that emulator finishes its server
thread and sets a flag which returns to the main activity which then
calls the .finish() method on the main activity.  The main Activity
appears to end normally. (The screen returns to the "home" screen of
the emulator).   However, the activity continues to act as a server
for the other emulator, accepting inbound connections forever.  The
only way to stop the connections is to close the emulator.  (It
doesn't stop the problem if I just click the "return" key or "home"
key on the emulator.)

Other details:
Before calling finish(), I specifically close() the serverSocket and
other sockets I have been using.
I have not specifically called my threads as services (which I know
can run in the background). I have just executed the threads in my
main activity as standard java threads...

I really don't understand why this should be happening.
Thanks for any insight!
Jim



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to