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 8646575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:50:47+00:00 2026-06-12T12:50:47+00:00

If a Ruby method creates threads, but joins them within the method, is that

  • 0

If a Ruby method creates threads, but joins them within the method, is that still considered a side-effect from a functional programming perspective? The implementation I’m using is YARV Ruby, in which threads are created by the operating system, albeit with a GVL (Global VM Lock).

The reason the threads are being created is to do system calls, which is a side effect anyway, but I’ve never come across anyone saying whether threads are or aren’t a side effect.

Simplified pseudo-code for this would look somewhat like the following:

  def run_tasks
    input_files = (1..4).map {|i| "input_#{i}"}
    output_files = (1..4).map {|i| "output_#{i}"}
    threads = [input_files, output_files].transpose.map |input_file, output_file|
      # system itself is a side effect
      Thread.new { system(["sub_program.rb", input_file, output_file]) }
    end
    threads.map(&:join)
  end
  • 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-12T12:50:48+00:00Added an answer on June 12, 2026 at 12:50 pm

    The passage of time is seldom considered a side-effect, so the use of threads to cause less time to take place is not a side-effect. This is analogous to the use of memoization to improve performance, which is also not a side-effect, even though it modifies hidden state.

    Note that input_files.zip(output_files) will work as well as [input_files, output_files].transpose, and may communicate your intent better.

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

Sidebar

Related Questions

I have a simple FileCreator Ruby class that has 1 method create which creates
I am attempting to build a simple method that creates an XML file from
I've got a Ruby method like the following: # Retrieve all fruits from basket
I have a Ruby method that searches an array of hashes and returns a
I have a ruby method (deactivate!) that is on an activeRecord class. However, I
Is it possible to define an instance method in ruby from a string (the
I would like to write a method in ruby that takes a class with
Some of you may know the method in Ruby that allows you to reverse
I this working Ruby code that i want to make an executable from with
As a programming exercise, I've written a Ruby snippet that creates a class, instantiates

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.