Exiting a class in the middle  
Author Message
braincracka





PostPosted: 2003-9-10 11:22:00 Top

java-programmer, Exiting a class in the middle 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
 
JustSomeGuy





PostPosted: 2003-9-10 11:38:00 Top

java-programmer >> Exiting a class in the middle Try hitting the breaks and return dude.

"BrainC" <email***@***.com> wrote in message
news:email***@***.com...
> 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


 
JustSomeGuy





PostPosted: 2003-9-10 11:48:00 Top

java-programmer >> Exiting a class in the middle Ohh ya and if the loops are making you sick... you can always throw("up");

"BrainC" <email***@***.com> wrote in message
news:email***@***.com...
> 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


 
 
Joona I Palaste





PostPosted: 2003-9-10 14:28:00 Top

java-programmer >> Exiting a class in the middle JustSomeGuy <email***@***.com> scribbled the following:
> 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***@***.com) ---------------------------\
| 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
 
 
Ryan Stewart





PostPosted: 2003-9-11 5:17:00 Top

java-programmer >> Exiting a class in the middle "BrainC" <email***@***.com> wrote in message
news:email***@***.com...
> 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.


 
 
braincracka





PostPosted: 2003-9-11 7:27:00 Top

java-programmer >> Exiting a class in the middle 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
 
 
braincracka





PostPosted: 2003-9-11 9:51:00 Top

java-programmer >> Exiting a class in the middle 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
 
 
braincracka





PostPosted: 2003-9-11 9:51:00 Top

java-programmer >> Exiting a class in the middle 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
 
 
JustSomeGuy





PostPosted: 2003-9-11 10:44:00 Top

java-programmer >> Exiting a class in the middle
"BrainC" <email***@***.com> wrote in message
news:email***@***.com...
> 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...


> BrainC