Monday, July 27, 2009

What is the meaning of keyword volatile in ‘c’ and please give me an example where we use it?

The volatile keyword indicates that a field can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread.





ex: shows how to declare a public field variable as volatile.


// csharp_volatile.cs


class Test


{


public volatile int i;





Test(int _i)


{


i = _i;


}


public static void Main()


{





}


}

apple

No comments:

Post a Comment