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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:22:01+00:00 2026-06-08T03:22:01+00:00

We are making an Excel-like system. When we open a document and found unsupported

  • 0

We are making an Excel-like system. When we open a document and found unsupported functions we threw exception. We just support small subset of excel functions, this could happen frequently. The problem is when there are a lot of cells that contains unsupported functions, lots and lots of exception instances are created. And creating those many exception instances consumes unignorable amount of time.

We don’t have any special properties within the exception class. What we need to know is the fact that the exception is thrown. We just found that the error has occurred and mark the cell as error.

So we decided to share one exception instance and throw it whenever needed. The exception instance can be thrown by multiple threads. I suspect that the stack trace could be corrupted, however, we don’t see it. We just catch the exception, and mark the corresponding cell as error.

My question is:
In this situation, is it safe to share exception instance?

Well, I read the following article:
Java: is Exception class thread-safe?
But the context seems to be different.

Thank you for reading this long question and response in advance.

  • 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-08T03:22:04+00:00Added an answer on June 8, 2026 at 3:22 am

    […] is it safe to share exception instance?

    Yes, if you’re careful.

    If you’re not careful, the getStackTrace for instance may get messed up. Either make sure each thread has it’s own exception object, or override getStackTrace and return an empty array.

    (The JVM actually reuses exception instances in some cases. If it runs out of memory, it will reuse a preallocated OutOfMemoryError instead of trying to create a new one for instance. In this case the getStackTrace returns an empty array.)

    Related question:

    • How can a preallocated OutOfMemoryError truthfully implement Throwable.getStackTrace if thrown twice?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am facing a problem while making Excel's LinEST function. My program goes like
I'm currently making a simple inventory system application using Excel VBA. I have a
I am making excel add-in in which clicking on menu item or toolbar button,
Is it possible to make some kind of link from SQL to Excel making
I stumbled on a way to crash excel in Workbook_Open while making an .xla
I'm using Delphi to make an XLL add-in for Excel, which involves making a
Making a word document of our network set-up. We have about 7 servers and
I am making a Excel Addin in VS2010. The following code work fines if
I am making an Excel 2010 spreadsheet that may end up having 400 -
I'm opening an Outlook email from Excel. I would like to format the body,

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.