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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:41:30+00:00 2026-05-20T19:41:30+00:00

My rule of thumb about using thread is: if multiple instances of the same

  • 0

My rule of thumb about using thread is: if multiple instances of the same object needs to run concurrently, use threads. But I am facing the design choice issue in a scenario similar to the one I am describing below. Please help me clarify this once and for all:


(Reusing the example from my previous
post)
I have 5 Pen object instances,
100 Author threads, and 3 Paper object
instances.
Any number of Authors may
be using any number of Pens to write
on any given paper.
I have created
blocking queue to protect the Pen
objects being accessed by Authors.
If all pens in the queue are used,
Authors wait.
The Pen instances take
data from Author threads and append it
to the (specified) Paper instance.
After updating Paper instance, Pen
also updates the invoking Author
thread.

Questions:

  • Is there value in running the Pen
    object as threads?
  • If so, how would I pass data from
    Author thread to Pen thread so that
    the Pen thread can execute the read
    (from author), write (to Paper), and
    write back (back to invoking Author
    thread) safely?
  • 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-20T19:41:31+00:00Added an answer on May 20, 2026 at 7:41 pm

    My first take would be that Authors are workers (i.e. possibly threads), while pen and paper are resources (i.e. no threads – only used by some workers).

    I would refactor the design to move the functionality from Pens to Authors. Also I would try to model Authors as Callables (or Runnables if there is no need to return any result) instead of threads, and run them within the Executor framework – this gives higher level abstractions to work with, resulting in cleaner and safer code.

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

Sidebar

Related Questions

I'm confused about which to use and when. Is there a rule of thumb?
Is there a rule of thumb as to when one should use path parameters
What rule of thumb do you use for deciding to use node_load() or just
The typical rule of thumb when it comes to using CSS sprites for images
const correctness has me somewhat confused. What rule of thumb do you use to
I know the rule-of-thumb to read declarations right-to-left and I was fairly sure I
A good rule of thumb by is that I intelligently refactor any method over
As as rule of thumb I generally put classes in a file of their
What's the rule of thumb for passing data in a REST URL in the
Anyone have a good rule of thumb for choosing between different implementations of Java

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.