Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Concurrent;
- using System.Threading;
- namespace ConqueueTest
- {
- class MainClass
- {
- private static ConcurrentQueue<Int32> queue = new ConcurrentQueue<Int32> ();
- public static void Main (string[] args)
- {
- Thread checker = new Thread (new ThreadStart (CheckQueue));
- checker.IsBackground = true;
- checker.Start ();
- int val = 0;
- while (true) {
- queue.Enqueue (1);
- while (!queue.TryDequeue(out val)) {
- }
- }
- }
- public static void CheckQueue ()
- {
- int val = 0;
- while (true) {
- queue.TryPeek (out val);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement