Link to home
Start Free TrialLog in
Avatar of systan
systanFlag for Philippines

asked on

Is it possible that multithreading wont work if my core is only 1

hi

I've build a basic multithreading of record type via tmemorystream

type
tmythread = class(tthread)
private
MStream:TmemoryStream;
StreamRec: pmyStreamRec; //packed record type
xscore: integer;
retvalue: integer;
procedure showStatus;
protected
procedure execute; override;
constructor Create(createsuspended:boolean);
end;
...
var  mythreads: array[0..max-1] of tmythread;  
...
  mythreads[0] := tmythread.Create(true);
   mythreads[0].MStream := db.tptStream1;
   mythreads[0].StreamRec := db.StreamRec1;
   mythreads[0].Resume;

   mythreads[1] := tmythread.Create(true);
   mythreads[1].MStream := db.tptStream2;
   mythreads[1].StreamRec := db.StreamRec2;
   mythreads[1].Resume;
...

Number of seconds WITHOUT using class tthread: 12s+-
Number of seconds USING class tthread with 2 threads: 12s+-

There the same.

What if I test this on dual core or quad core?,  What possibly is the result?

What is your analysis?
Avatar of Geert G
Geert G
Flag of Belgium image

owch , my eyes !
where is the indenting ?

and the implementation of the threads ?
SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of systan

ASKER

hi Geert;
I don't understand what you mean.
I have only 1 core cpu, with intel celeron 1.6hz and free memory 500mb.
my bad for not having a detail.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, I forgot to tell : Of course a multithreaded application will work on 1 Core machine.
But as I said, get some gains from that is another story
Avatar of systan

ASKER

Thanks
systan,
you are lacking the knowledge about the ins and outs of multithreading
as you don't get the basics you won't be able to grasp the answers
> finding the bottlenecks
> protecting the shared resources
> synchronizing multiple threads
> dividing tasks into smaller pieces in multiple threads
> using a threadpool
> reporting back out of the threads

read up on these topics:
http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/ToC.html
or download here :
http://cc.embarcadero.com/item/14809

covering a lot:
http://delphi.about.com/od/kbthread/Threading_in_Delphi.htm
oh ... forgot what i find the state of the art piece for multithreading
check the OTL ! (OmniThreadLibrary)

http://www.thedelphigeek.com/