I have a question about how the System class works.
Lets say there is a server which creates a thread for each client that connects to it, and a thread calls System.out.println(message) at some point. Which computer will have that message printed out? Is it the server’s computer or the client computer? Does it matter which side created the thread?
It will be on the server.
It’s impossible for the client to create a thread on the server (and vice-versa). The server can create new threads in response to connections from the client, but that’s totally different.
Simply put: If the code is running on the server,
System.outoutputs on the server unless someone overrides normal behavior viasetOutand implements aPrintStreamthat outputs via a socket stored in local thread storage. And they won’t, it would be a nutso thing to do. 🙂