View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004116 | JEDI VCL | 00 JVCL Components | public | 2007-04-28 23:55 | 2007-12-18 01:52 |
Reporter | adit_bose | Assigned To | obones | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0004116: Bug in JvThread | ||||
Description | I've used JvThread in my application. While using it, I've found a bug in the ThreadTerminate method, that can be seen in the attached program (Source). On calling JvThread.Terminate after ThreadExecute or ThreadExecuteAndWait, it does NOT terminate. It is Terminated by passing a boolean value (QuitThread). | ||||
Additional Information | The thread is Terminated by passing a boolean value (QuitThread), but this is not the proper way to terminate the thread because, this sample program instantiates on a loop, what if there is no loop? | ||||
Tags | No tags attached. | ||||
2007-04-28 23:55
|
ThreadBugSource.zip (361,759 bytes) |
|
I can't understand why do you complain about it as bug? It's "as gesigned" (see TThread documentation). TThread has no method for killing thread in Win32 API TerminateThread style. Terminate only sets internal flag Terminated and nothing more. Execute must check this flag and exit if Terminated=true. To use conventional termination mechanism replace Execute method in your progect with procedure TForm1.JvThread1Execute(Sender: TObject; Params: Pointer); var ThisThread: TJvBaseThread; begin ThisThread:=Sender as TJvBaseThread; repeat until ThisThread.Terminated = true; end; or with procedure TForm1.JvThread1Execute(Sender: TObject; Params: Pointer); begin repeat until JvThread1.Terminated = true; // slower end; For more information see for example Subject: TThread sleep and terminate. Date: Tue, 11 Dec 2007 Message-ID: <475df57e$1@newsgroups.borland.com> in borland.public.delphi.language.delphi.win32 |
|
Terminating a thread with TerminateThread() is dangerous. What if the thread is in a critical section or owns an IPC object (Mutex, Semaphore, ...). Deadlocks will be the result. |
|
You can also use the TerminateWaitFor method, which combines the Terminate and the Waitfor procedures. Added to svn at 18. November. |
|
Well, I then consider this fixed. |
Date Modified | Username | Field | Change |
---|---|---|---|
2007-04-28 23:55 | adit_bose | New Issue | |
2007-04-28 23:55 | adit_bose | File Added: ThreadBugSource.zip | |
2007-12-16 17:16 | AHUser | Project | JEDI API & WSC Library => JEDI VCL |
2007-12-16 17:23 | AHUser | Category | ASPI and SCSI => 00 JVCL Components |
2007-12-17 02:25 | AlexB | Note Added: 0014079 | |
2007-12-17 12:11 | AHUser | Note Added: 0014081 | |
2007-12-17 12:16 | AHUser | Note Edited: 0014081 | |
2007-12-17 17:13 | jfudickar | Note Added: 0014083 | |
2007-12-18 01:51 | obones | Status | new => resolved |
2007-12-18 01:51 | obones | Resolution | open => no change required |
2007-12-18 01:51 | obones | Assigned To | => obones |
2007-12-18 01:51 | obones | Note Added: 0014084 |