Exiting a class in the middle

B

BrainC

I am working on a multi-threaded server-socket application. I already
have lots of crazy loops which are needed in order to function
properly.

What I need to add is a function that once all the people logged-on
exited, the server would be ready to accept connections again.

IS THERE A COMMAND THAT WOULD BREAK THROUGH THE CLASS AND EXIT IT
ANYWHERE TO GO BACK TO THE CLASS, WHICH CALLED IT (IN MY CASE BACK TO
MAIN).

I tried Label:

continue Label;

but I really do have messy loops that won't let this work properly.

I also thought maybe "System.exit(1);" would work, but that terminates
the whole application.

Any suggestions would be very appreciated.

Little BrainC
 
J

Joona I Palaste

JustSomeGuy said:
Ohh ya and if the loops are making you sick... you can always throw("up");

Expect that you can't, as ("up") is a String and String is not a
subclass of Throwable.

You can do this, however:
Throwable up = new Throwable();
throw up;

--
/-- Joona Palaste ([email protected]) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"You can pick your friends, you can pick your nose, but you can't pick your
relatives."
- MAD Magazine
 
R

Ryan Stewart

BrainC said:
I am working on a multi-threaded server-socket application. I already
have lots of crazy loops which are needed in order to function
properly.

What I need to add is a function that once all the people logged-on
exited, the server would be ready to accept connections again.
Question: If the server isn't listening for connections all along, how would
you get people logged in after the first one anyway?
IS THERE A COMMAND THAT WOULD BREAK THROUGH THE CLASS AND EXIT IT
ANYWHERE TO GO BACK TO THE CLASS, WHICH CALLED IT (IN MY CASE BACK TO
MAIN).
It's not necessary to shout.
I tried Label:

continue Label;

but I really do have messy loops that won't let this work properly.
No comment.
I also thought maybe "System.exit(1);" would work, but that terminates
the whole application.
System.exit(int status) stops execution of your application. I assume that
the status is similar to the DOS errorlevel. One way or the other, a
non-zero status indicates abnormal termination.
 
B

BrainC

Hey JustSomeGuy

Thanks for taking the time to write to me. But I'm not sure how to
put to practice what you've said. Throwable class is just an error
detector (as far as I could see). And I don't really follow what you
mean by break and returns.

Again, all I wanted to know was, whether there is some kind of an
escape method to terminate the running class and returned it to the
class which instantiated it, or maybe some method that would throw the
executing line back to the top of the class.

Thanks,
BrainC
 
B

BrainC

Ryan and everyone

Thank you very much for your help. I actually managed to crack this
one. I was being stupid before. What I ended up doing at the end was
giving the method "runserver()" a return statement and then simply
resetting the socket listener.

JustSomeGuy you're not just some guy you are my hero, if it wan't for
you I would probably be still messing around with the "break" and
"continue" statements.

BrainC
 
B

BrainC

Ryan and everyone

Thank you very much for your help. I actually managed to crack this
one. I was being stupid before. What I ended up doing at the end was
giving the method "runserver()" a return statement and then simply
resetting the socket listener.

JustSomeGuy you're not just some guy you are my hero, if it wan't for
you I would probably be still messing around with the "break" and
"continue" statements.

BrainC
 
J

JustSomeGuy

BrainC said:
Ryan and everyone

Thank you very much for your help. I actually managed to crack this
one. I was being stupid before. What I ended up doing at the end was
giving the method "runserver()" a return statement and then simply
resetting the socket listener.

JustSomeGuy you're not just some guy you are my hero, if it wan't for
you I would probably be still messing around with the "break" and
"continue" statements.
Hey you seemed really stressed and I wanted to give you something to laugh
about for a change.
Of course I meant throw and catch...
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top