This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I developed a JEE application,in spring and hibernate .All my business logic are simple POJO.While I design I never worried about Mutlthreading.I deployed my application in Tomcat.
As per my understanding servlet are multithreaded so many request comes to access the same servlet then it will be mutithreaded.
In my application , to get a value from database 3 objects in service layer and 2 objects in persistence layer are involved
1)if many users want to access my application at a time for getting value from database ,then server(tomcat) create each thread for a user that means all the 5 objects(service layer+persistence layer) are multithreaded and given to single user? so each thread contain 5 objects?
Server will create separate thread to serve all users only when they send the request simultaneously if there is time difference among request then it is possible that only couple of treads can serve 5 users.
About how many instances will be created, all that depends how you coded your application. For example if there is a singleton class then one instance will be shared by all threads.
Objects aren't multi-threaded - they are or are not threadsafe. Which one of those is the case depends on how you wrote them. And whether it's a problem if they're not depends on whether they're exposed to multiple threads. As Vinod said, we can't speak to that, because we don't know how your code creates and uses those objects.