Forget about the source of a thread. That is not important. All code executes on a thread. Then consider what the API doc that you read says:
Only one thread at a time can own an object's monitor.
Type: Posts; User: Norm
Forget about the source of a thread. That is not important. All code executes on a thread. Then consider what the API doc that you read says:
Only one thread at a time can own an object's monitor.
One thread you are given by the JVM. Use that one to handle user input.
You create one thread to wait on the messages from the server.
None of the code I've written that has used synchronized...
Yes that is what I mean.
All code runs on a thread. You can get a thread several ways.
Extending Thread is ONE way. Using new Thread() is another way to create a new thread when you need to have...
None of them do.
Extending the Thread class is not an issue.
Please post a link to the other forum.
I'm always interested in learning new techniques:
If the client does not have a separate thread for listening for messages from the server, how does it work?
One way clients work is to build a GUI,...
Ok. But bottom line: all code executes on a thread. Your program is given one thread to execute on when it starts. If you need more, use the Thread class to ask the JVM to give you another one.
objects don't execute. The code in an object executes on a thread. In fact the code in an object can execute on several different threads concurrently.
If the loop that waits is on its own thread,...
All code executes on a thread.
That makes the communications like broadcasts. There are no expected responses to the message being sent. So there is no waiting for the response. Send the message...
Not sure what would happen or why you want to do it that way.
What do you mean by the "client object"? Execution is in threads. Objects contain methods and data.
I would create a thread for each...
Then you would need to use a thread for each send message/receive response communication.
How does the client work? Does it send a message to the server and then wait for the response?
If you need the client to be doing something else while it is waiting for the response, then put the...