FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
August 01, 1999
Win32 Multithreading Made Easy

(Page 1 of 4)
John Harrington
Multithreading logic is hard to write and hard to maintain. So keep it simple and separate.
August 1999/Win32 Multithreading Made Easy/Figure 1

Figure 1: An example application

/* =======================================================
Main.cpp
======================================================= */

#include "derived.h" #include "multithread.h" #include <iostream>

int main() { using namespace std; const int nSize = 26; int loop;

// Create threadable objects

Derived ObjectArray[nSize]; for (loop = 0; loop < nSize; ++loop) { // letters of the alphabet ObjectArray[loop].SetChar('a' + (loop % 26) ); }

// Create threads

MultiThread ThreadArray[nSize]; for (loop = 0; loop < nSize; ++loop) { ThreadArray[loop].Initialize( &ObjectArray[loop], 10 ); ThreadArray[loop].Run(); }

// Wait until they finish

for (loop = 0; loop < nSize; ++loop) { ThreadArray[loop].WaitUntilDone(); }

cout << endl; return 0; }

1 | 2 | 3 | 4 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.
DR. DOBB'S CAREER CENTER
Looking for a new job? open | close
Search jobs on Dr. Dobb's TechCareers
Function:

Keyword(s):

State:  
  • Post Your Resume
  • Employers Area
  • News & Features
  • Blogs & Forums
  • Career Resources

    Browse By:
    Location | Employer | City
  • Most Recent Posts:



    MICROSITES
    FEATURED TOPIC

    ADDITIONAL TOPICS

    INFO-LINK



     




    Techweb
    Informationweek Business Technology Network
    InformationweekInformationweek 500Informationweek 500 ConferenceInformationweek AnalyticsInformationweek Events
    Informationweek MagazineGlobal CIOIWK Government ITbMightyByte and SwitchDark Reading
    Digital LibraryIntelligent EnterpriseInternet EvolutionNetwork ComputingPlug Into The CloudDr. DobbsContentinople
    space
    TechWeb Events Network
    InteropVoiceConWeb 2.0 ExpoWeb 2.0 SummitEnterprise 2.0Mobile Business ExpoNoJitter
    Black HatGTECEnergy CampCloud ConnectGov 2.0 ExpoGov 2.0 Summit
    space
    Light Reading Communications Network
    Light ReadingLight Reading AsiaUnstrungCable Digital NewsInternet EvolutionPyramid Research
    Heavy ReadingLight Reading LiveLight Reading InsiderEthrnet ExpoTelco TVTower Technology Summit
    space
    Financial Technology Network
    Advanced TradingBank Systems and TechnologyInsurance and TechnologyWall Street and TechnologyAccelerating WallstreetBST SummitBuyside Trading SummitIT Summit
    space
    Microsoft Technology Network
    MSDNTechNetTotal IT ProTotal Dev ProNET Total Dev Pro CommunitySQL Total Dev Pro Community
    space