Multi-threaded app running procedures on a module...

W

WATYF

Hi there... I have a simple question. I have a multi-threaded app where
different threads run procedures and functions on a single module.
Obviously, it's possible that two (or more) threads could be running
the same procedure on the module at the same time. Is this bad? If so,
why?

This is a huge module with tons of procedures/functions on it, and I'm
thinking of converting it to a class so that a new instance can be
created by each thread, but I want to make sure it's worth it first.

Thanks for any help.


WATYF
 
T

TDC

It's not code that you have to worry about, it's data. As long as
there are no modular-level variables in your module (for example, if it
is just filled with utility methods) then you are safe.

Tom
 
W

WATYF

Right... there are no module level variables (except for the ones that
I want to be accessible by all threads). It's just a bunch of utility
methods/functions. I was just wondering about the code aspect, since
they could be executing the same code at the same time.


WATYF
 
C

Chris Dunaway

Just make sure that you synchronize access to the module level
variables that are accessible to all threads.
 
C

Chris Dunaway

You would need to use the SyncLock statement to lock the variable,
something like this:

SyncLock var
'Code to change the var
End SyncLock

Look up the SyncLock statement in the docs and it should have more
examples.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top