LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Real application using threads (https://www.linuxquestions.org/questions/programming-9/real-application-using-threads-610515/)

Ashok_mittal 01-02-2008 01:28 AM

Real application using threads
 
Hi all,

Greetings for new year.Can anyone give me some hints about writing
a real application using threads.I have studied threads programming like creating,join,condition variables and made progarms to understand the concept now i want to make an application so that i can fully understand this concept.
Regards
Ashok

jtshaw 01-02-2008 07:51 AM

Not sure exactly what your looking for here but the first thing I did using threading was a very simple server application.

It spawned a thread for listening for connections. When a connection came in it spawned a thread to handle the particular connection and the listening thread then went back to listening for new connections. When the connection was dropped the thread to handle it went away.

The next step was to make it a little more intelligent. I created a thread for listening and 5 threads that's jobs were to handle established connections based on who needed handling (by having each of them wait on a select call). This is effectively a very basic example of thread pooling.

Ashok_mittal 01-03-2008 12:29 AM

Sir i am looking for an application based on threads just like the hint you have given to me.Can u explain me more about this server application.


Quote:

Originally Posted by jtshaw (Post 3008479)
Not sure exactly what your looking for here but the first thing I did using threading was a very simple server application.

It spawned a thread for listening for connections. When a connection came in it spawned a thread to handle the particular connection and the listening thread then went back to listening for new connections. When the connection was dropped the thread to handle it went away.

The next step was to make it a little more intelligent. I created a thread for listening and 5 threads that's jobs were to handle established connections based on who needed handling (by having each of them wait on a select call). This is effectively a very basic example of thread pooling.



All times are GMT -5. The time now is 07:37 AM.