From my understanding, each vert.x instance will be assigned an event loop. Event loop handles all the request an other task for that particular instance. Event loop is a thread, I think. When there are multiple vert.x instance deployed, each instance have there own event loops right? That means there are multiple thread(multi-threading) exists. This is how I understood. This single-threading concept causing me so much headache. Any help will be appreciated.
How vert.x is single threaded?
6.3k Views Asked by Ronald Randon AtThere are 2 best solutions below
Mr__Steel
On
Vert.x is not single threaded like node.js. In vert.x you have to differentiate between Verticles and WorkerVerticles. One Vert.x instance will create several event loops (which are threads), usually one per CPU-core. The Verticles will be assigned to an event loop and will always be executed by the same thread, but only if there is work to do. The WorkerVerticles will be assigned to a thread coming from the worker pool and can be executed by different threads. What makes programming fun with Vert.x is the fact that you can "pretend" it is single threaded. You do not have to care about concurrency because you cannot share variables between verticles. Each verticle runs in its own classloader and you can only share data via the event bus. (There is also a shared map but that is distracting in this case.)
Related Questions in JAVA
- I need the BIRT.war that is compatible with Java 17 and Tomcat 10
- Creating global Class holder
- No method found for class java.lang.String in Kafka
- Issue edit a jtable with a pictures
- getting error when trying to launch kotlin jar file that use supabase "java.lang.NoClassDefFoundError"
- Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
- Mixed color rendering in a JTable
- HTTPS configuration in Spring Boot, server returning timeout
- How to use Layout to create textfields which dont increase in size?
- Function for making the code wait in javafx
- How to create beans of the same class for multiple template parameters in Spring
- How could you print a specific String from an array with the values of an array from a double array on the same line, using iteration to print all?
- org.telegram.telegrambots.meta.exceptions.TelegramApiException: Bot token and username can't be empty
- Accessing Secret Variables in Classic Pipelines through Java app in Azure DevOps
- Postgres && statement Error in Mybatis Mapper?
Related Questions in MULTITHREADING
- How can I outsource worker processes within a for loop?
- OpenMP & oneTbb difference
- Receiving Notifications for Individual Task Completion OmniThreadLibrary Parallel.ForEach
- C++ error: no matching member function for call to 'enqueue' futures.emplace_back(TP.enqueue(sum_plus_one, x, &M));
- How can I create a thread in Haskell that will restart if it gets killed due to any reason?
- Qt: running callback in the main thread from the worker thread
- Using `static` on a AVX2 counter function increases performance ~10x in MT environment without any change in Compiler optimizations
- Heap sort with multithreading
- windows multithreading CreateMutex
- The problem of "fine-grained locks and two-phase locking algorithm"
- OpenMP multi-threading not working if OpenMPI set to use one or two MPI processor
- WPF Windows Initializing is locking the separated thread in .Net 8
- TCP Client Losing Connection When Writing Data
- vc++ thread constructor throwing compiler error c2672
- ASP.NET Core 6 Web API : best way to pause before resending email
Related Questions in VERT.X
- Vert.x modify content of static file
- how to avoid while loop while waiting for future complete?
- Can Eclipse Vert.x support phpmyadmin?
- How to retrieve the managed Router instance in Quarkus
- how to implement vertx webclient mtls?
- Is it possible to create few service proxies with the same method names?
- Quarkus Keystore Password File
- Can verticle consumer handler be executed by the eventloop thread other than the eventloop thread on which it is deployed?
- Should I use ContextInternal when building Vertx Retry mechanism based on Resilience4j?
- How to fix the incompatibility issue for Vertx-core 4.5.4 version with smallrye-reactive-messaging-kafka
- InterruptedException occurred when using Vertx's executeBlocking with JDK ExecutorCompletionService starting from Vertx v4.3.0
- How to asign a class to the results of a Mutiny.Query
- Vertx Async Confusion running async code in a method returning Future
- Vertx Oracle Null-Value on SQL-INOUT-Parameter
- Guaranteed and ordered delivery in event bus of Vert.x?
Related Questions in SINGLE-THREADED
- How to handle a multi thread tests calling a single thread web service in .Net Framework 4.6?
- Read multiple sockets from single thread [low-latency]
- Concern regarding Cloud Run server instance creation delays
- How to Capture Each New Millisecond Without Overwhelming the CPU
- Does Tokio have run_until_stalled equivalent?
- netty 4; how to initialize client's connection from same thread synchronously
- Is CPU frequency the only limiting factor for single threaded MySQL performance
- Is it necessary to create a Java singleThreadPool when the method is already handled in an async way?
- Can a nodejs process use more than 100% CPU?
- Why cant the system find the file that is specified?
- What does it actually mean by the term 'single-threaded process' specific to PHP and how and why does the request get blocked in this case?
- How to achieve single threaded concurrency with blocking functions in Rust?
- Differences between Node.js Thread Pool and Clustering Node.js
- How to make an ASP.NET app to be single threaded
- Single-threaded concurrency in Python
Related Questions in SINGLETHREADMODEL
- Initializing the COM library in apartment threaded mode in a thread with no message loop
- How to set node server to run different requests simultaneously?
- How can .NET Core compare to Node.js when it still has the context switch overhead?
- Node JS multiple concurrent requests to backend API
- SingleThreadModel is deprecated and does not guarantee thread safety, what is the best soluation/design approch to guarantee thread safety in Servlet?
- How JBoss 4.2.3 implements SingleThreadModel (STM): 1 instance of a servlet OR multiple instances of a servlet?
- How vert.x is single threaded?
- How to create a STA (Single Threaded apartment) control in VS2010
- (Servlets, Thread safety) Protecting the session and context state
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You probably figured it out by now, but I am posting an answer for other people that might reach this question.
A vert.x instance will create multiple threads. Inside that vert.x instance you have multiple verticles (verticle instances more accurately) running. It is a verticle instance that has an event loop assigned, but that event loop is not exclusively assigned to that verticle.
Overlaps can happen when you are running more verticles that the number of threads. In that case some of the verticles will be assigned to the same event loop as other verticles. That event loop will process events from all the assigned verticles.
But, once a verticle instance is started and assigned to an event loop/thread, it will run on it until the verticle is terminated.