Call a different method from a class that is already running as thread?

J

Jan Liße

Hi,
i was wondering if it is possible to call a method (not run()) from a class,
that is already running
as a thread in the background. I want to do this, because i have got a main
class and from this
main class i start another class as background thread that works as a
receiver on a socket-connection.
But i need to send data over my socket too, and i am not sure if i should
place the method
for sending in my background-thread class, (if it is even possible) or if i
have too write a new
class just for the sending method. In the latter case i am not sure if it is
possible to pass one
object (my socket) from main-class to two other classes, working with the
same object.
I dont need the sending to be done in thread, besides.
Somehow confused about that,
thanks for any help!
Jan
 
J

Joona I Palaste

Jan Liße said:
Hi,
i was wondering if it is possible to call a method (not run()) from a class,
that is already running
as a thread in the background. I want to do this, because i have got a main
class and from this
main class i start another class as background thread that works as a
receiver on a socket-connection.

As long as you've got a reference to the object that has its run()
method running as a thread, you can call any methods you wish on it.
Knock yourself out!

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"'So called' means: 'There is a long explanation for this, but I have no
time to explain it here.'"
- JIPsoft
 

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
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top