1. What is deadlock?
2. When do you deadlock use and how it use ?
3. Explain integer overflow in detail.
4. What does "static" mean?
1. What is deadlock?
2. When do you deadlock use and how it use ?
3. Explain integer overflow in detail.
4. What does "static" mean?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 18, 2012, 4:14 PM
2. Deadlock is something which you need to avoid, not use! In complex multithreaded situations, this is easier said than done.
3. Integer overflow occurs when an arithmetic operation causes an integer to exceed its maximum value. By default in C#, this causes the integer to wrap around i.e. incrementing the maximum value results in the minimum possible value.
However, you can use the 'checked' operator to thow an OverflowException rather than wrap around behaviour.
Integer underflow, where an arithmetic operation causes an integer to fall below its minimum value wraps around in the opposite direction i.e. decrementing the minimum value results in the maximum possible value.
4. The 'static' keyword means that a member of a class (or struct) relates to the class as a whole and not to a particular instance of it.
It can also be applied to a class which means that all its members must be static, constant or nested types. A static class cannot be instantiated and is implicitly sealed.
VulpesPosted May 20, 2012, 6:18 AM
http://www.c-sharpcorner.com/UploadFile/1d42da/deadlock-in-threading-in-C-Sharp/
The following is an example of integer overflow which also includes the use of static members:
using System;
class MyClass
{
public static int MyInt;
public int YourInt;
}
class Test
{
static void Main()
{
int i = Int32.MaxValue;
Console.WriteLine(i); // 2147483647
i++; // increment i
Console.WriteLine(i); // -2147483648 due to wrap around to maximum negative value
MyClass mc = new MyClass();
mc.YourInt = 3; // an object needs to be created to set the instance field YourInt
Console.WriteLine(mc.YourInt); // 3
MyClass.MyInt = 4; // an object is not needed to set the static field MyInt - class name used instead
Console.WriteLine(MyClass.MyInt); // 4
Console.ReadKey();
}
}
David SmithPosted May 20, 2012, 1:17 AM
can you give me an example of integer overflow
can you give me an example of static?