Home > AS/400 Tips > iSeries administrator tips > Introduction to multi-threaded programming -- part 1
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES ADMINISTRATOR TIPS

Introduction to multi-threaded programming -- part 1


Ron Turull
11.09.2006
Rating: -4.37- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



Ron Turull

Multi-threaded programming was introduced on the AS/400-iSeries back in V4R2, but was limited to C and Java programs. Multithreaded programming took a big step up with the release of V4R4 when multithreaded support was added to the RPG and COBOL languages. But multithreaded programming on the iSeries is still a work in progress.

What is multithreaded programming?

A thread – short for thread of control -- is a path of execution that a program takes. All the programs you have created in the past on the AS/400-iSeries have been "single-threaded" applications. That is, your programs have followed a single path only of execution at any given time. True, the path may vary depending on conditions and control structures at the time of execution, but there is one path only of execution at any given time. For example, when you see a program trace, you see just a single column of instructions -- a single path of execution, a single thread -- not multiple columns of instructions.

Multi-threading is the ability of a program to spawn additional, simultaneously-executing paths of execution. Put another way, it is the ability to have multiple "parts" of a program executing at the same time. Think of it as a client-server application with both the client part and the server part in the same program. In fact, that is one of the best applications for multi-threaded programming.

Advantages of multithreaded programming

The main advantage of multithreaded programming is the ability to spawn off some code to run in the "background" while the rest of the program does something else. For example, consider the typical order-entry program described in the following flowchart. It shows a single path of execution.

Now consider the next flowchart. It is the same application, but this time it is split into two paths of execution that will execute simultaneously. The first path is called the primary thread. It allows the user to enter the customer's order. When the order is complete, it spawns off a secondary thread that will run in the "background" to update the inventory files, process backorders for any items that are out of stock, and write the order to the order-entry files.

Meanwhile, the primary thread allows the user to immediately enter the customer's payment information (e.g., credit card number, COD, terms, etc.). When that is complete, the primary thread joins with the secondary thread; that is, it waits for the secondary thread to end, which will probably already be finished in this case.

This is advantageous because it allows the user to work uninterruptedly, instead of waiting while the program is processing something else. We'll take a look at the mechanics of multithreaded programming next time.

-----------------------------------
About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.


Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries administrator tips
Analyze the health of your IBM i server with iScore
Researching high availability for your System i shop
Translating Linux for IBM i admins: Using GUI to make it easy
Translating Linux for IBM i admins: Working with jobs and networking
OpenOffice: What to know before making the transition from Microsoft Office
OpenOffice: An enterprise open source solution
Database performance comparisons on IBM i
Translating Linux for IBM i admins: User profile commands
Modern System i reports using Client Access
Tips for installing Lotus Domino server on a System i partition

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts