-2

I found some sample code establishing a multi-threaded chat server, written with the intent of being expanded into a simple MUD on this website: http://bytes.com/topic/c-sharp/answers/275416-c-mud-telnet-server

The thread is quite old, so I can't ask any questions there, so I figured I'd turn to the kind folks at stackoverflow to help explain something to me.

Before I get into writing a MUD, I'd like to understand how the above code (which I intend to use as a base to get started) works, so I can modify the basic architecture if I need things to work differently. What I don't understand though, is how it can be starting new threads with each Connection which instantiates its own ArrayList of connection, which it only adds itself to, but still communicate with other users.

I'm assuming it's some basic lack of understanding of how threads work or something of the sort, but no matter how long I stare at that code I can't figure it out.

Thanks in advance, HJD

  • 1
    -1. Agree. "Teach me programming" is not a valid topic. – TomTom Mar 13 '11 at 06:57
  • 1
    -1. Please post the code in your question. Stack overflow posts should be more-or-less self-contained. If I have to click a link to figure out what you are asking, you didn't ask it right. – Merlyn Morgan-Graham Mar 13 '11 at 06:58

1 Answers1

2

Ah, the ArrayList in question is static, which means that it's shared by ALL instances of the Connection class.

zvrba
  • 24,186
  • 3
  • 55
  • 65
  • Oh, right... I guess it's just sort of weird because I imagine the compiler seeing a new instance of Connection and starting at the header, seeing the "new ArrayList();" and creating a new one each time. Thanks though, when I think about it that clears everything up. – HankJDoomstorm Mar 13 '11 at 06:34