2 ms·
IMO, the main problem with using threads is that they are such an 'all or nothing' approach to sharing data. If you want to make use of multiprocessing, the tr
by joosters 9y ago
IMO, the main problem with using threads is that they are such an 'all or nothing' approach to sharing data.
If you want to make use of multiprocessing, the traditional choice is either to use two separate processes (sharing nothing), or to use threads (and share everything). But for most tasks, these opposite ends of the spectrum are not what you need. There's plenty of data and state in most programs that doesn't need to be shared, and a huge source of threading bugs is through mistakenly altering some data that another thread was using.
The problem is that sharing partial state between processes is painful and many languages and OSs make it difficult to do. You have to play around with mmap() or other shared memory tools, and then pay great attention to not mix pointers or other incompatible data between the processes.