Link to home
Create AccountLog in
Avatar of jhofb
jhofb

asked on

problem with threads

i´ve the following problem : i've a multithread application and when i start only one thread (the other thread is waiting for an event) it works fine. But when the second thread (or some more) is also running, i get an error which i can't locate. How can i fix this error ? The threads are created with CreateProcess from which a Class-method is called.
I get one of these two errors's :
PROJEKT WT2K.EXE raised Exceptionclass EInvalidPointer with message "Invalid Pointer Operation". Prozess stoped. Press step or run.
PROJEKT WT2K.EXE faulted with Message "Accessviolation at 0x00401d01 write of adress 0x001 process stopped ...

Avatar of jhofb
jhofb

ASKER

The threads are created with CreateThread(nil, 16384, @RRunTime, Pointer(self), 0, RTThreadID);
Avatar of jhofb

ASKER

.. and i use delphi 5
Hi jhofb

Can you send some sample code ?

why don't you use the vcl TThread class ?

Your looks like problem looks like you are not protecting common resources as tightly as you think :

for instance lets say that you have something like this

function getmyobject(i) : tmyobject
....
criticalsection.enter
result := myobject
criticalsection.leave

and

procedure freemyobject(i)
....
criticalsection.enter
.....
myobject.free
criticalsection.leave

and in the thread you have :

amyobject := getmyobject ....

and using amyobject

you can get errors like this

HTH

Marc

What about syncronization and critical resources!
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jhofb

ASKER

Adjusted points to 155
Avatar of jhofb

ASKER

madshi,
thanks for this very very very very ... good answer (i`ve been searching to solve this problem for over 20h) thanks.
nearly i desired to sell my computer and get a farmer
155 all i had

Thanx for the point boost...  :-)