hilleybilley
BAN USER
#include <iostream>
using namespace std;
int main()
{
int powerOfTwo;
char exit = 'n';
while( exit=='n')
{
cout << "Enter number :";
cin>> powerOfTwo;
if(powerOfTwo==0)
{
cout << "Number is 0 only.";
}
if(!(powerOfTwo &(powerOfTwo-1)))
{
cout<<"Number is Power of 2..."<<endl;
}
else{
cout<<"Number is not power of 2..."<<endl;
}
cout << "Do you want to exit ? Y/N" << endl;
cin >>exit;
}
return 0;
}
it is simple no need to use any locking or anything.
public class RCExample
{
int maxNumber = 100;
int number = 1;
public void PrintEven()
{
while (number < maxNumber)
{
if (number % 2 == 0)
{
// Console.WriteLine(number);
Console.WriteLine(Thread.CurrentThread.Name + " " + number + " ");
number++;
}
}
}
public void PrintOdd()
{
while (number < maxNumber)
{
if (number % 2 != 0)
{
// Console.WriteLine(number);
Console.WriteLine(Thread.CurrentThread.Name + " " + number + " ");
number++;
}
}
}
}
and
Thread evenThread = new Thread(new ThreadStart( raceCondition.PrintEven));
evenThread.Name = "Even Thread :";
Thread oddThread = new Thread(new ThreadStart( raceCondition.PrintOdd));
oddThread.Name = "Odd Thread :";
evenThread.Start();
oddThread.Start();
we can use a deadlock where it's negative effects are far less than it's positive effects. Like
If i start my car in the morning, My smart car monitoring system can stumble into deadlock and just wont let me start. Deadlock reasons should be seriously good.
Please provide better example
Repjacobghester2, Accountant at ASAPInfosystemsPvtLtd
I'm an artist at heart. I went from print design to web development and lots of server administration professionally ...
RepJaneBraun, Associate at ASAPInfosystemsPvtLtd
Hi, I am Jane From York,PA.My goal is to create a life that I don’t want to ...
Repkiyanshak, Associate at Adobe
I am a skilled software developer and have 5 years experience as a data coder operator. I have certain skills ...
total count of set bits in the given number.
- hilleybilley January 23, 2016