[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Threads



On Wed, 16 Jun 1999, Pierre Phaneuf wrote:

>Brad Johnson wrote:
>
>>         Okay, I admit it... I know next to nothing about threads. My current
>> project is rather simple, and hasn't needed anything past Xlib. Can anyone
>> point me to some good information on threads?
>
>IMHO, just avoid them. ;-)
>
>Really, do you actually *need* them?

Well, well... How do you then monitor for instance sockets for incoming
data? Poll them every second? Attach them through select():s to some
event-loop somewhere? The second approach would be IMO the only sane
thread-less solution, but using a thread for the socket-IO is very clever.
It can just read the socket, preprocess the data a bit and throw it on a
queue somewhere, from which it can be fetched by the main loop when
needed. Simple tasks can be taken entirely care of by the thread, thus
decreasing the workload (not system load) for the main part.

---------------------+------------------------------------------------------
 Jan 'Chakie' Ekholm |    CS at Åbo Akademi University, Turku, Finland
    Linux Inside     | I'm the blue screen of death, no-one hears you scream