Skip to content

Commit ab8da33

Browse files
committed
Docs on System.exit, debugging
1 parent 4956e7f commit ab8da33

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

doc/other/best-practices.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ Accidental concurrency is often cited as a problem with using `Future`s: if you
4646
a method returns Ox's `Fork`. Hence, avoid returning `Fork`s from methods. Instead, model concurrency on the caller's
4747
side - if something should be run in parallel, the caller can do so, using `supervised` and `fork`, and by calling
4848
blocking methods within the forks.
49+
50+
## Debugging virtual threads
51+
52+
Virtual threads are normally not visible when using tools such as `jstack` or IntelliJ's debugger. To inspect their
53+
stack traces, you'll need to create a thread dump to a file using `jcmd [pid] Thread.dump_to_file [file]`, or use
54+
Intellij's thread dump utility, when paused in the debugger.

doc/utils/oxapp.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ When the application receives a SIGINT/SIGTERM, e.g. due to a CTRL+C, the root s
2424
forks) are interrupted. This allows for a clean shutdown: any resources that are attached to scopes, or managed using
2525
`try-finally` blocks, are released. Application shutdown is handled by adding a `Runtime.addShutdownHook`.
2626

27+
```{warning}
28+
When using `OxApp`, within an Ox-managed fork (thread), do not use `System.exit` or `sys.exit` to shut down your
29+
application. This will cause a deadlock with the cleanup process. For more details see
30+
[#368](https://github.com/softwaremill/ox/issues/368).
31+
```
32+
2733
In the code below, the resource is released when the application is interrupted:
2834

2935
```scala mdoc:compile-only

generated-doc/out/other/best-practices.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ Accidental concurrency is often cited as a problem with using `Future`s: if you
4646
a method returns Ox's `Fork`. Hence, avoid returning `Fork`s from methods. Instead, model concurrency on the caller's
4747
side - if something should be run in parallel, the caller can do so, using `supervised` and `fork`, and by calling
4848
blocking methods within the forks.
49+
50+
## Debugging virtual threads
51+
52+
Virtual threads are normally not visible when using tools such as `jstack` or IntelliJ's debugger. To inspect their
53+
stack traces, you'll need to create a thread dump to a file using `jcmd [pid] Thread.dump_to_file [file]`, or use
54+
Intellij's thread dump utility, when paused in the debugger.

generated-doc/out/utils/oxapp.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ When the application receives a SIGINT/SIGTERM, e.g. due to a CTRL+C, the root s
2424
forks) are interrupted. This allows for a clean shutdown: any resources that are attached to scopes, or managed using
2525
`try-finally` blocks, are released. Application shutdown is handled by adding a `Runtime.addShutdownHook`.
2626

27+
```{warning}
28+
When using `OxApp`, within an Ox-managed fork (thread), do not use `System.exit` or `sys.exit` to shut down your
29+
application. This will cause a deadlock with the cleanup process. For more details see
30+
[#368](https://github.com/softwaremill/ox/issues/368).
31+
```
32+
2733
In the code below, the resource is released when the application is interrupted:
2834

2935
```scala

0 commit comments

Comments
 (0)