如何与多个客户共享一个程序? (意味着多个客户端线程共享相同的对象?)

"How a single program is accessed by multiple clients"?

"Is any copy of the program generated for each client to consume the program"?

The question is too simple but still a bit confusing. Consider a piece of pseudo-code below-

Class Some {
// Some code
}
main(){
Some s= new Some();
}

So, now if a client tries to access this piece of code an object 's' will be created.

The question is whether this object will be created for every client(or client request) who accesses the code or this object will be created once in a lifetime(means on the deployment of code)?

I know servlets (or any other container based on language) are used to handle client requests but I am asking about the program which we write to be consumed by multiple clients.

In order to understand the concept, I think you will need to delve into the details of Java Memory Model. I think this link is a great resource for beginners.

Class Some {
  // Some code
}
main(){
  Some s= new Some();
}

The question is whether this object will be created for every client(or client request) who accesses the code or this object will be created once in a lifetime(means on the deployment of code) ?

When you pass/access s, that's passing the value of s, which is a reference to a Some object. (s itself is passed by value) that wouldn't change which object s referred to. Java is strictly pass-by-value)

When you change the value within that object using s.someDataMember, then looking at the value of someDataMember again by another client will see the updated value.

Basically, Java doesn't copy objects unless you really ask it to. Now I am referring to this in the context of same JVM process.

Now consider that this object is an immutable object.