Advertisement
Guest User

Untitled

a guest
Oct 11th, 2011
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Concurrent;
  3. using System.Threading;
  4.  
  5. namespace ConqueueTest
  6. {
  7.     class MainClass
  8.     {
  9.        
  10.         private static ConcurrentQueue<Int32> queue = new ConcurrentQueue<Int32> ();
  11.        
  12.         public static void Main (string[] args)
  13.         {
  14.             Thread checker = new Thread (new ThreadStart (CheckQueue));
  15.             checker.IsBackground = true;
  16.             checker.Start ();
  17.             int val = 0;
  18.             while (true) {
  19.                 queue.Enqueue (1);
  20.                 while (!queue.TryDequeue(out val)) {
  21.                 }
  22.             }
  23.         }
  24.        
  25.         public static void CheckQueue ()
  26.         {
  27.             int val = 0;
  28.             while (true) {
  29.                 queue.TryPeek (out val);
  30.             }
  31.         }
  32.        
  33.     }
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement