Threads which just read data - Programmer

This is a discussion on Threads which just read data - Programmer ; Hi, I have many threads in my program. I would like to know if it is safe to allow the threads access to a global variable to just read its contents, without having a synchronizing object ? I don't see ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Threads which just read data

  1. Threads which just read data

    Hi,
    I have many threads in my program. I would like to know if it is safe
    to allow the threads access to a global variable to just read its
    contents, without having a synchronizing object ?
    I don't see any reason why it will be unsafe to allow threads to
    just read contents, without having a synchronizing object. Please
    correct me if I'm wrong.
    Thanks,
    -Venkatesan

  2. Re: Threads which just read data

    Venkatesan wrote:
    > Hi,
    > I have many threads in my program. I would like to know if it is safe
    > to allow the threads access to a global variable to just read its
    > contents, without having a synchronizing object ?
    > I don't see any reason why it will be unsafe to allow threads to
    > just read contents, without having a synchronizing object. Please
    > correct me if I'm wrong.
    > Thanks,
    > -Venkatesan


    It is safe for many threads to read any variable without synchronizing
    if you are sure that the variable will not change while the threads are
    running.

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread