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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:23:06+00:00 2026-05-16T03:23:06+00:00

My software uses multiple threads to do its work. There is a pipeline that

  • 0

My software uses multiple threads to do its work. There is a pipeline that looks something like this:

                   +-----------------+
                   |+-----------------+
+------------+     ||+-----------------+     +------------+
|            |     |||                 |     |            |
| Get and    |     ||| Worker Threads  |     |  Save      |
| feed work  |--->>|||                 |--->>|     Output |
|            |     |||   Do Work       |     |            |
+------------+     +||                 |     +------------+
                    +|                 |
                     +-----------------+

Each box represents a separate thread. The arrows between them are thread safe queues for “work” objects to flow through. The “Get and feed work” thread pulls waiting work from the database and feeds it to a pool of worker threads. Those worker threads do some work, updating a status flag on the work object (and storing it to the db) as well as producing some output objects. The output objects flow to the “Save Output” thread where they are saved and/or updated in the database.

The purpose of this architecture is mainly one of queuing efficiency.

I need the “Get and Feed Work” thread to have its own DB session/connection so it can continuously read from the DB, unblocked, and feed that data to the worker threads.

Each worker thread also needs their own DB connection/session mainly to update their progress in the DB on whatever task they are working on. These DB connections/sessions are always low-impact, infrequent updates. Each worker thread produces something significant that requires an insert into the DB. Instead of each worker thread doing its own insert, it pushes that responsibility down the line to the “Save Output” thread.

The “Save Output” thread gains efficiency writing to the DB by doing it in batches – inserts are much faster in batches than one at a time.

I’m beginning to think Hibernate may not be appropriate for this architecture.

I’m finding myself running into lots of issues dealing with Hibernate sessions, evicting, merging, clearing, flushing, oh my.

My architecture seems stable currently but it also seems extremely inefficient. Would it be better to abandon Hibernate and use straight JDBC?

  • 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-16T03:23:06+00:00Added an answer on May 16, 2026 at 3:23 am

    Hibernate sessions and objects loaded from sessions are not thread safe so they cannot be accessed by different threads simultaneously, however it’s ok to access them from different threads sequentially. From the description of your process, there does not seem to be overlap between the threads so you should be fine passings the objects and the session.

    Make sure not use thread bound sessions though, don’t use SessionFactory.getCurrentSession()

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

Sidebar

Related Questions

I work on a project that uses multiple open source Java libraries. When upgrades
I am working a software that uses Qt and has existing methods to encrypt/decrypt
I'm working on a plugin for Avogadro (chemistry software) that uses pyqt. I've some
What is the biggest software development team that uses Python? I am wondering how
I´m developing a software in C# that uses static functions from a C++ .dll
Hi I have some software written in VB6.0 that uses an SQL Server, but
I develop a software that uses FlatOPC files. I need to manipulate several parts
I am writing some software that uses ffmpeg extensively and it is multi threaded,
To summarize my issue, I work at a company that uses a laser to
This samplet is from a project I am working on. My client uses software

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.