[Lazarus] making multithreading more user friendly

Giuliano Colla giuliano.colla at fastwebnet.it
Sat Apr 28 01:24:03 CEST 2012


Maybe I'm affected by bad luck, but almost all applications I happen to 
develop must run under Linux and must deal with data coming at 
unpredictable times from some external connection. It may be a network 
connection, a serial device, a special device, but always coming in an 
unpredictable way.

Possible scenarios are:

1) Freezing the GUI for an undetermined amount of time, waiting for data

2) Loosing the data arriving while the GUI is doing something else.

3) Both sometimes freezing the GUI and sometimes loosing the data.

4) Take advantage of multithreading, have separate threads which monitor 
and process incoming data, and then neatly synchronize with GUI.

For some obscure reasons, neither I nor my customers find the first 
three options acceptable, so I usually I'm forced to select the fourth one.

I boldly start a new Application, begin to populate my window with 
required gadgets, write the thread code, push F9, and my Application 
crashes. Then I revise my code, looking for all obvious errors, and 
after a painful search, I discover that I had either forgot to add 
-dUseCThreads to program options, or , even worse, that I had simply 
misspelled it.

 From the posts I see from time to time in this list, it appears that 
I'm not the only one to suffer this sort of problem.

Now I know that it's been debated if multithreading should be enabled by 
default in Unix environment, and the conclusion has been that it should 
not. I can't say that I found the arguments against multithreading very 
convincing, but I don't want to reopen a closed discussion.

What I ask is: would it be so hard to provide the choice in the "New" 
dialog? Something like Single Thread Application and Multi Thread 
Application? The choice could be either hidden or flash an error for the 
platforms where multithreading is not supported, would be a no-op for 
Windows, but would make life easier to the rest of us.
I could provide a patch if pointed to the right area of code to deal 
with. IDE things remain a big mystery to me.

Giuliano





More information about the Lazarus mailing list