Skip to content
Sign UpLog In
Profile icon

Marco Tessarotto

@MarcoTessarotto
Repls
Community
MarcoTessarotto
MarcoTessarotto
published a Repl
7 months ago
0
TryWithResources
TryWithResourcesin this example, try with resources is used to create a few instances of MyTask. MyTask implements AutoCloseable, so the close method of all MyTask instances will be called on exit from try block. when calling close method on a MyTask instance, its internal status must be "ok to close" before effectively releasing its resource, else close method will wait.