acceptAndOpen() blocks / Who to stop a thread in j2me

R

Richard Lavoie

Hallo everybody,

I'm trying to write a client/server application which uses bluetooth
to do the communication.
Wenn I start the server, I have to start acceptAndOpen() to wait for
incomming connections of the clients.
My Problem ist that if there isn't any client the function above will
block the application.
What I tried was to start it as a thread by making the class server
runnable.
The problem now ist how to stop this thread (in particular
acceptAndOpen()).
There isn't a method Thread.stop() or suspend() in j2me.
What I tried to was to make a dummy connection to server to get out of
acceptAndOpen(). But this ist't the nice way to do it.

Any help, please!!!

Richard
 
D

Darryl L. Pierce

Richard said:
Hallo everybody,

I'm trying to write a client/server application which uses bluetooth
to do the communication.
Wenn I start the server, I have to start acceptAndOpen() to wait for
incomming connections of the clients.
My Problem ist that if there isn't any client the function above will
block the application.

The above should be in a *separate* thread. You're blocking yourself by
executing that on the main thread.
What I tried was to start it as a thread by making the class server
runnable.
The problem now ist how to stop this thread (in particular
acceptAndOpen()).

Call close() on the Connection object.
There isn't a method Thread.stop() or suspend() in j2me.

Nor in J2SE. It's deprecated.
What I tried to was to make a dummy connection to server to get out of
acceptAndOpen(). But this ist't the nice way to do it.

Any help, please!!!

Call close() and code your Runnable object to exit its run() method.

--
/**
* @author Darryl L. Pierce <[email protected]>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,269
Messages
2,571,100
Members
48,773
Latest member
Kaybee

Latest Threads

Top