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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:07:58+00:00 2026-05-25T20:07:58+00:00

I have nested class CRecursion which has method that do recursion. This CRecursion created

  • 0

I have nested class CRecursion which has method that do recursion.
This CRecursion created in many threads. Is safe call from thread method from main class?
Thanks.

class A {
method1() {....}

for(int i=0;i<100;i++){
   execute(new CRecursion(...))
 }

protected CRecursion {

calculate (par){
  if (some_condition) {
     calculate(par1)
 } else {
  String s=method1(value);
  .....
 }

}
....
}

Variable value is Object. But internal for each method.

  • 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-25T20:07:59+00:00Added an answer on May 25, 2026 at 8:07 pm

    If the objects used by the recursive routine are confined to the same thread, then yes, the recursive routine is thread-safe. It would help to read this related StackOverflow question on thread confinement and it’s impact on thread-safety.

    In this particular case (with the code that you’ve posted), you’ll need to ensure that:

    • The arguments to the constructor of CRecursion must not be shared across multiple threads. If they are shared, then the following point becomes relevant.
    • Any objects that are shared across multiple threads, must not be accessed (read from or written to) in the recursion routine.
    • The recursion routine uses local variables that are confined to the current stack frame. The routine must not access any other shared storage area (other than the Java call stack) to exchange data between invocations.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing several class templates that contain nested iterator classes, for which
I'm using NHibernate. I have a class which has a nested type. Is there
I have a class, which has a protected nested class , and a protected
I have a class whereby a method calls a nested class. I want to
Assume the following: we have class B, which is a private class nested inside
I have implemented a nested class in Java, and I need to call the
I have two closely related classes which I'll call Widget and Sprocket. Sprocket has
I have a Forum model, whose instances can have many nested forums: class Forum
I have a static nested class, which I would like to return via a
I have a class library that is nested two+ layers under a main GUI

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.