oktonion, еще раз: смотри документацию BCB! Или ты думаешь, что там только мышкой кликать надо?
Смотри в доке "Writing multi-threaded application".
Добавлено через 2 минуты и 7 секунд:Using the main VCL/CLX thread
When you use objects from the VCL or CLX object hierarchies, their properties and methods are not guaranteed to be thread-safe. That is, accessing properties or executing methods may perform some actions that use memory which is not protected from the actions of other threads. Because of this, a main thread is set aside to access VCL and CLX objects. This is the thread that handles all Windows messages received by components in your application.
If all objects access their properties and execute their methods within this single thread, you need not worry about your objects interfering with each other. To use the main thread, create a separate routine that performs the required actions. Call this separate routine from within your thread’s Synchronize method. For example:
void __fastcall TMyThread::PushTheButton(void)
{
Button1->Click();
}
void __fastcallTMyThread::Execute()
{
...
Synchronize((TThreadMethod)PushTheButton);
...
}
Synchronize waits for the main thread to enter the message loop and then executes the passed method.
Note: Because Synchronize uses the message loop, it does not work in console applications. You must use other mechanisms, such as critical sections, to protect access to VCL or CLX objects in console applications.
You do not always need to use the main thread. Some objects are thread-aware. Omitting the use of the Synchronize method when you know an object’s methods are thread-safe will improve performance because you don’t need to wait for the VCL or CLX thread to enter its message loop. You do not need to use the Synchronize method for the following objects:
Data access components are thread-safe as follows: For BDE-enabled datasets, each thread must have its own database session component. The one exception to this is when you are using Microsoft Access drivers, which are built using a Microsoft library that is not thread-safe. For dbDirect, as long as the vendor client library is thread-safe, the dbDirect components will be thread-safe. ADO and InterbaseExpress components are thread-safe.
When using data access components, you must still wrap all calls that involve data-aware controls in the Synchronize method. Thus, for example, you need to synchronize calls that link a data control to a dataset by setting the DataSet property of the data source object, but you don’t need to synchronize to access the data in a field of the dataset.
For more information about using database sessions with threads in BDE-enabled applications, see Managing multiple sessions.
DataCLX objects are thread-safe although VisualCLX objects are not.
Graphics objects are thread-safe. You do not need to use the main VCL or CLX thread to access TFont, TPen, TBrush, TBitmap, TMetafile (VCL only), TDrawing (CLX only), or TIcon. Canvas objects can be used outside the Synchronize method by locking them.
While list objects are not thread-safe, you can use a thread-safe version, TThreadList, instead of TList.
Call the CheckSynchronize routine periodically within the main thread of your application so that background threads can synchronize their execution with the main thread. The best place to call CheckSynchronize is when the application is idle (for example, from an OnIdle event handler). This ensures that it is safe to make method calls in the background thread.
Добавлено через 3 минуты и 11 секунд:Defining thread objects
For most applications, you can use a thread object to represent an execution thread in your application. Thread objects simplify writing multi-threaded applications by encapsulating the most commonly needed uses of threads.
Note: Thread objects do not allow you to control the security attributes or stack size of your threads. If you need to control these, you must use the Windows API CreateThread or the BeginThread function. Even when using Windows Thread API calls or BeginThread, you can still benefit from some of the thread synchronization objects and methods described in Coordinating threads.
..........
Добавлено через 32 секунды:Цитировать можно до утра...