Tag: Thread
How to avoid race condition in shared resources in Java?
Natan Ferreira- 0
- 333
Sharing resources between threads can be a challenging task, as it requires ensuring that operations are atomic. What is a resource? A resource can be variables, data structures, files, messages, etc. In Java, we have two important memory areas: the Stack and the Heap. Why use shared resources between threads? There are many reasons, but…
Read More
How to run tasks in parallel with timeout in Java?
Natan Ferreira- 0
- 950
The use of Threads is essential to improving the performance and responsiveness of modern applications. With threads, it is possible to execute multiple tasks simultaneously, maximizing processor resources. They allow intensive operations, such as calculations or accessing external resources (e.g., databases, APIs), to be performed in parallel without blocking the main execution. Imagine the following…
Read More