Skip to content

Create a single place for all chunky thread/executors to be registered - #1895

Open
NotStirred wants to merge 13 commits into
chunky-dev:masterfrom
NotStirred:fix/non_daemon_threads
Open

Create a single place for all chunky thread/executors to be registered#1895
NotStirred wants to merge 13 commits into
chunky-dev:masterfrom
NotStirred:fix/non_daemon_threads

Conversation

@NotStirred

@NotStirred NotStirred commented Jul 8, 2026

Copy link
Copy Markdown
Member

I'm not tied to any of the specifics here, but having a mechanism to wait on chunky to join its threads is very important with Bedrock.
Essentially leveldb is thread safe on reads, so I don't want to lock. If region parsers/chunk loading are active when the DB is closed it races and results in almost always a segfault/pthread lock error. The ChunkyThread#joinAll() lets the shutdown hook wait for everything before closing the db.

Closes #1893

  • Allows chunky to close threads on shutdown without a System.exit()
  • Additionally provides an api to wait on all chunky threads to be joined.

@NotStirred
NotStirred requested review from ThatRedox and leMaik July 8, 2026 15:13
Comment thread chunky/src/java/se/llbit/util/concurrent/ChunkyThread.java Outdated
if (waitTime > 0) {
thread.join(waitTime); // joining with 0 is infinite wait time, very intuitive.
}
// Thread.isAlive() establishes a happens-before with the thread. As such the following are non-issues:

@NotStirred NotStirred Jul 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is stated in JLS17 at: 17.4.4:

The final action in a thread T1 synchronizes-with any action in another thread T2 that detects that T1 has terminated.

@NotStirred
NotStirred force-pushed the fix/non_daemon_threads branch from 652e737 to e69129b Compare July 26, 2026 20:25
@NotStirred NotStirred mentioned this pull request Jul 26, 2026
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Most threads are marked as non-daemon

2 participants