Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

19.4 A Common Multithreading Mistake

Let's assume you have the following application code:

Here a separate thread (say, thread A) is created to handle the dataClose() method invocation. The main thread may exit earlier than thread A, which results in undesirable behavior when thread A exits. This is a common mistake. Though the int library attempts to hide multithread programming issues under the hood, you must be aware of this situation. The solution, provided in the commented-out line below line //1, ensures that thread A exits before the main thread goes out of scope, by forcing the IOU to be redeemed. This blocks the main thread until the dataClose() operation has completed.



Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.