Forums Register Login

Looking for Base Idea behind Multithreading Concept

+Pie Number of slices to send: Send
Hi All

Please help me to think about multithreading basic concept.

Let say we have a web application which is deployed on an application server , now how the multi-threading will come into picture , how does that situation comes when we say same variable is getting used by two or multiple instances or requests . when we should start thinking about multithreading during our development time. I understand synchronization , wait , sleep , notify and all those things but not able to understand exactly when do i need it? whose job is this to handle multithreading .. Web Server or Code ..

In a very short sentences , if somebody can guide me before we say i have two threads .... or Thread A is writting while Thread A is reading or something like this.

Thanks in advance , looking for good discussion.


Thanks
+Pie Number of slices to send: Send
Hi ankit,(Regarding how web-server works)

Thread:Thread is nothing but small small prog executed on perticular system.

Lets take one small example..Say take Facebok .There are 'n' numbers of users of fb.Now when you open the browser and hit fb.com a defult thread is created which is my main thread.When you login to that system another thread is created which is registered under your user id and all the opreration regarding to your profile will keep track by your thread only.Smilarly there are billion number of thread created by web-server to to give concurrent users to use one site.
1
+Pie Number of slices to send: Send
Although I know RatiKanta pal is trying to be helpful here, I think I have to speak up and say that essentially all of this is factually wrong. Web servers don't create one thread per user, and Facebook.com is most certainly not running billions of threads in parallel.

Nor are all the requests for a given user handled by one thread; a small pool of threads handles requests as they come in, without concern for previous history. The number of threads in the pool is based on what the server hardware can handle, not on the number of users. State for a user is held in cookies in the web browser and and in session objects on the server; the session objects are examined by code running in a thread that handles a request.

Threads in a web server allow multiple requests to be handled at once. Multiple threads can be calling the service method of a single servlet object at the same time, and they won't interfere, as long as there is no data that must be shared between threads.

If your servlet objects have member variables whose values can change during execution, then you need to be concerned about writing multithreaded code. Most of the time, however, this isn't a concern, as you don't normally store data like that in your servlets. As I said, you store it in the session.
+Pie Number of slices to send: Send
hi Ernest Friedman-Hill,

Thank you for your information.

Previously i was assuming , session is one thread.and though that thread all operation carried out..Now i think its clear to me.

Rati.
Squanch that. And squanch this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 930 times.
Similar Threads
Please help me!
Multi Files Transfer from client machines to server machines using socket communication in java
One thread as a scheduler on webserver
client-side scripting?
Where do your book shines ?
Locking Schemes: Tactical View 01
NX: File Consistency
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:09:50.