2
Answers

ERROR- inavalid token BOOL in class

JUKE BOX

JUKE BOX

9y
680
1
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)
Next Recommended Forum