JUKE BOX

JUKE BOX

  • NA
  • 28
  • 7.5k

ERROR- inavalid token BOOL in class

Dec 13 2014 3:17 AM
i wrote a program of thread as  below and it is showing error as INAVALID TOKEN BOOL IN CLASS,INTERFACE OR METHOD

using System;
using System.Threading;
namespace ConsoleApplication1
{
public class worker
{
public void dowork()
{
while (!_shouldstop)
{
Console.WriteLine("doworker thread is proessing ");
}
Console.WriteLine("doworker thread is terminating ");
}
public void requeststop()
{
_shouldstop=true;
}
private Volatile bool _shouldstop;
}
public class workerthreadex
{
static void Main()
{
worker ws = new worker();
Thread th = new Thread(ws.dowork);
th.Start();
Console.WriteLine("main function starting do work thread");
while(th.IsAlive)
{
Thread.Sleep(1);
}
ws.requeststop();
th.Join();
Console.WriteLine("thread terminated successfully");
Console.ReadKey();
}
}
}

Answers (2)