Let's assume you have the following application code:
void main() { RWIFtpClient client; ... // do file transfer processing ... // incorrect !!! client.dataClose(); //1 // instead, use: RWBoolean b = client.dataClose(); // or assign to IOU and use the callback mechanism // or assign to IOU and use the polling mechanism }
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.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.