I want to start a thread which opens a socket. The socket sends and receives data.
How can I access this thread from another class which is running a timer? I want to update values to the socket on a timer. These values will then be used to write to the so开发者_运维知识库cket stream.
How can I access this thread and call other classes from within it?
I think this is about wiring your application.
In simple cases you can do it in plain Java using constructions parameters, setters and getters, static references, ...
In complicated cases you can use JNDI or use Dependency Injection frameworks like Spring Framework or Google Guice.
精彩评论