Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:43:54+00:00 2026-06-17T12:43:54+00:00

I have a question about multithreading in Delphi. Suppose, I have a thread and

  • 0

I have a question about multithreading in Delphi.
Suppose, I have a thread and I have a some class, that do some work and must have synchronization. How I can make it?
I make this procedure (In ThreadClass):

procedure TThreadClass.SynchProc(P: TProc);
begin
 ...
 Synchronize(TThreadProcedure(P));
 ...
end;

And I call it from my class, that running in Thread, but …
In procedure symbol “Synchonization” is a method of TThread, that is object “(Self as TThread)”, but when I call it proc from my class, variable “Self” doesn’t contain a my ThreadClass object (I dont know, that it’s contained, may be object of second class, that running in Thread). respectively that procedure does not work.
I search oth variants (I’m passed my threadClass object to second class object and try to call “Synchronization” procedure from procedure of second class, but compiller did not want to compile it).

Can you help me? Will be grateful for any help

with greetings from Ukraine
PS Sorry for my bad English

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:43:55+00:00Added an answer on June 17, 2026 at 12:43 pm

    I’m not 100% sure I understand, but I think you have a situation like this. You have a TThread descendent, say TMyThread. And that class in turn uses another class named TThreadClass which does not descend from TThread. You want to call Synchronize from a method of TThreadClass.

    Here are some options:

    1. Pass the TThread instance to TThreadClass. This is a rather brutal solution to the problem. Now TThreadClass can do anything to the thread when all it wants to do is call Synchronize.
    2. Pass a procedural variable referring to the Synchronize method to TThreadClass. This gives TThreadClass the ability to do what it needs and no more.
    3. Call the TThread.Synchronize class method passing nil for the first parameter.

    Of these, the final option is the simplest. You can do it like this:

    procedure TThreadClass.SynchProc(P: TThreadProcedure);
    begin
      TThread.Synchronize(nil, P);
    end;
    

    Note that it is not a good idea to pass in a TProc and cast to TThreadProcedure as per the code in the question. Force the caller to pass in a procedural variable of the right type. In this case the cast is benign, but you should always aim to avoid casts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Little question about Ruby error handling. I have some code that roughly resembles the
I have question about normalization. Suppose I have an applications dealing with songs. First
I have a question about SqlDataReader: Is there some way to modificated the values
I have question about database optimizing, indexing. I have table that called projects and
I have question about throw. How will the throw work in the following code?
I have question about the sql query. I am trying to make the query
I have a question about multithreading in xcode. I have searched for numerous web
So I've read some stuff about multithreading and NSOperation and wondering how I can
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.