Hey guys, I am playing with the .NET 4.0's new class Parallel. I tried to open files in a directory and calculate the total bytes of them. However when I run the code, I get a different result every time. Can you explain me the problem I have? [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; using System.Runtime.Remoting.Messaging; using System.IO; using System.Drawing; namespace LearnCSharp { class Program { static long totalBytes = 0; private static object token = new object(); static void ProcessImages() { string directoryPath = @"C:\files"; string[] fileNames = Directory.GetFiles(directoryPath); if (fileNames …

Member Avatar
Member Avatar
+0 forum 5

Hi folk. Can I use join() method in implementation of run(), like this: [CODE] public class MyThread extends Thread { @Override public void run() { int timeout = 30000; // here is some heavy work join(timeout); } } [/CODE] Is above thread terminated after timeout milliseconds if task takes longer time? I'm planning to use this thread with thread pool and want to terminate it if task takes longer time than timeout. [CODE] ExecutorService executor = Executors.newFixedThreadPool(10); MyThread mythr = new MyThread(); executor.execute(mythr); [/CODE] Please, give me some suggestions...

Member Avatar
Member Avatar
+0 forum 13

Hi all, Is there a way to make thread pools in POSIX pthreads? (using c) I could only find implementations for java and c++, but I need it to be in c. Thanks.

Member Avatar
Member Avatar
+0 forum 3

The End.