Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6997747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:19:21+00:00 2026-05-27T20:19:21+00:00

I am trying Mono/.Net 3.5 under Linux (Ubuntu). I tried to use threads in

  • 0

I am trying Mono/.Net 3.5 under Linux (Ubuntu). I tried to use threads in Mono, but it doesn’t seem to work properly.

public static void Main (string[] args)
{
    Thread thread =new Thread(()=> fn("first"));
    Thread thread1=new Thread(()=> fn("second"));
    thread.Start();
    thread1.Start();
}

static void fn(string name)
{
    for(int i=0;i<10;i++)
        Console.WriteLine(i+"  "+name);
}

Both loops run sequentially, as if I am not using threads.

What is wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:19:22+00:00Added an answer on May 27, 2026 at 8:19 pm

    Running this on Windows, most of the time all the first thread’s writes happen before the second thread’s.

    The loop is too trivial to really see the effects of multiple threads running concurrently. The first thread may simply finish before the second starts.

    Try putting a Sleep or spin loop in the main loop.

    for(int i=0; i<10; i++) {
        Console.WriteLine(i+" "+name);
        Thread.Sleep(10);
    }
    

    or

    for(int i=0; i<10; i++) {
        Console.WriteLine(i+" "+name);
        for(int j=0; j<100000; j++);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the Html.AntiForgeryToken in ASP.NET MVC under Mono (XSP) and it
Heya, I'm trying to use Mono's SIMD to handle coordinates(X,Y,Z) in my project, but
I am trying to run a .NET command line application in Linux using Mono.
I'm trying to use use code get a screenshot in Mono C# but I'm
I'm trying mono develop on linux, but trying to create a package, gives me
I'm trying to do an informal feasibility study for work on if Mono/Apache/Linux is
I am trying to use the Mono.TextEditor assembly with .NET Framework 3.5 in GTK#.
I am trying to port a small console application from Windows/.NET to Ubuntu/Mono. I
I'm trying to port a .NET application from Windows to Mono, but certain code
Hi I'm trying to use mono-service2 to run a stock Windows Service Project from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.