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

  • Home
  • SEARCH
  • 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 9045163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:12:29+00:00 2026-06-16T11:12:29+00:00

Just for fun I created a mandelbrot program. I’m now trying to make it

  • 0

Just for fun I created a mandelbrot program. I’m now trying to make it multithreaded by splitting the image into two left/right parts to be handled by two threads. However, the application crashes as soon as it’s launched (although based on my console output, the first thread continues after the crash but the second thread never starts) and I’m unsure what to do.

The crash is at the line this.output[x][y] = this.calculate_pixel_rgb(x, y); and says I’m missing an object reference, which I don’t understand because it works for the first thread.

    public void compute_all()
    {
        this.setcolors(); this.zoom_multiplier = (4 / this.zoom / this.resolution);
        Thread thread1 = new Thread(new ParameterizedThreadStart(computation_thread)); thread1.Start(new double[] { 0, 0.5 });
        Thread thread2 = new Thread(new ParameterizedThreadStart(computation_thread)); thread2.Start(new double[] { 0.5, 1 });
        thread1.Join(); thread2.Join();
    }

    public void computation_thread(object threadinfo)
    {
        double[] parameters = (double[])threadinfo;

        this.output = new int[this.resolution][][];
        for (int x = (int)(this.resolution * parameters[0]); x < (int)(this.resolution * parameters[1]); x++)
        {
            this.output[x] = new int[this.resolution][];
            for (int y = 0; y < this.resolution; y++)
            {
                this.output[x][y] = this.calculate_pixel_rgb(x, y);
                this.pixels_completed++;
            }
        }
    }
  • 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-06-16T11:12:32+00:00Added an answer on June 16, 2026 at 11:12 am

    Your two threads are manipulating the same output buffer, overwriting each other. Don’t share memory between threads if you can possibly avoid it; all it causes is grief.

    If the point of this exercise is to learn how to manipulate raw threads then take a step back and study why sharing memory across two threads is a bad idea.

    If the point of this exercise is to parallelize the computation of a fractal then forget about manipulating raw threads. You will do much better to learn how to use the Task Parallel Library.

    Threads are logically workers, and who wants to manage a bunch of workers? The TPL encourages you to see parallization as the manipulation of tasks that can be done in parallel. Let the TPL take care of figuring out how many workers to assign to your tasks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just for fun I created a project that created about 5 GB of memory
I'm making myself a little messenger just for fun. And I want to make
I'm trying to make Erlang program that finds prime numbers with processes (ineffective, I
Just for fun I created an algorithm that computes every possible combination from a
PRoblem: i'm trying to create (just for fun) a simple poker card (with a
Just for fun, I wrote this simple function to reverse a string in Python:
Just for fun, how close can we get to debug an application in C#
I built (just for fun) 3 classes to help me log some events in
I'm writing some code (just for fun so far) in Python that will store
I'm learning about AI and (just for fun and practice, not profit or anything

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.