Multithreading in C#

Dear Friend

I want to implement thread in C# for mean,median and mode functions.
in which the calculation will be in the following sequance

1. Mean [x' = (x/n)]
2. Median [M = ((n+1)/2)]
3. Mode [z = (2M+3x')]

can you help me.

Thanks in advance

 



Answer this question

Multithreading in C#

  • mobigital

    Yes Ilyas you are right but I was also right , because its understood that a function to calculate mean will need to have some parameters on which it has to do work. Its quiet obvious.

    Second, Do you really think that he's doing some professional work I think he's just trying Multithreading. How it works so this idea came to his mind and he started working on that. Thread is costly and we don't deny from this reality! But I think hes just doing practise with it.

    Best Regards,

    Rizwan



  • constm

    thanks for your co-operation on this matter but what i would want i have 3 different function mean,median,mode and the function mean will execute first and then median and at last mode how can i do this can you.

    thanks.


  • Rainadaman

    You can create and start thread who do the work for you:

    Thread meanThread = new Thread(new ThreadStart(CalculateMean));

    meanThread.Start();

    private void CalculateMean(/* Paramters here*/)

    {

    // Logic here

    }

    Note: Do no forget to reference System.Threading

    Same for others!

    I hope this will help!

    Best Regards,

    Rizwan



  • SAinet

     RizwanSharp wrote:

    You can create and start thread who do the work for you:

    Thread meanThread = new Thread(new ThreadStart(CalculateMean));

    meanThread.Start();

    private void CalculateMean(/* Paramters here*/)

    {

          // Logic here

    }

    That's not correct. You need to use ParameterizedStart method if you wanted to start a thread which calls a method which contains parameters as inputs.

     

    I wouldnt understand why you wish to start up threads to do calculations - unless they REALLLY take a LOOONNGG time to complete. threading is expensive so use it only when you think you need to.



  • Crasch

    See the Thread.Join() function, it'll do work for you. Better explore MSDN to see what does it do.

    I hope this will help you but in case of any problem you can come back!

    Best Regards,

    Rizwan Ahmed



  • Multithreading in C#