Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. class InternalClass{    Thread t = null;    public InternalClass()  {
  2.         t = new Thread( new ThreadStart( ThreadFunction ) );                    t.Start();  }
  3.     /// Internal Thread Function    private void ThreadFunction()   {
  4.         // Simulate startup     Thread.Sleep( 10000 );
  5.         Console.WriteLine( "ThreadFunction Startup Complete trying to call lock(this)" );
  6.         // loop forever     while( true )       {           lock(this)          {
  7.                 Console.WriteLine( "Running Internal ThreadFunction - Starting(takes 3 seconds)" );
  8.                                 // do some work             Thread.Sleep( 3000 );
  9.                 Console.WriteLine( "Running Internal ThreadFunction - Complete" );          }       }   }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement