[Lazarus] Threads in Lazarus code base
nc-gaertnma at netcologne.de
Wed Sep 15 18:44:19 CEST 2010
On Wed, 15 Sep 2010 11:49:42 -0300
Luiz Americo Pereira Camara <luizmed at oi.com.br> wrote:
> Mattias Gaertner escreveu:
> > *many IDE parts will become slower (once you start a thread the RTL
> > uses critical sections and especially string handling become much
> > slower).
> If i understand correctly all program will suffer the performance hit,
> not only the "threaded" part, right?
Correct. As long as another thread runs. When the thread stops all
returns to "normal".
> Do you have an idea of how slower string handling would be?
That heavily depends on the string operations you do. I saw two
threads running slower than single threaded.
> I'm asking this because i'm planning to make a client of a REST service
> through http and i choose Synapse to do the communication.
> Since Synapse recommends to use thread to avoid GUI freeze, i planned to
> use a thread for getting the data.
In this case you have not much choice.
> At the other side this REST server uses JSON as the data format.
> If the thread really affects badly the string handling (and parsing JSON
> does a lot of it) i would rethink the strategy and go for an event
> based http client like lnet.
For performance relevant parts you should use PChar instead of strings.
Even when doing single threaded.
I mentioned the speed difference because this thread is about using
multi threading in the IDE and what advantages/disadvantages this
The IDE is special in many ways, so don't take the comments of this
thread as a general advice for your own programs.
More information about the Lazarus