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
- Add image to JCheckBoxMenuItem
- How to access invisible Unordered List element with Selenium WebDriver using Java
- Inheritance in Java, apparent type vs actual type
- Java catch the ball Game
- Access objects variable & method by name
- GridBagLayout is displaying JTextField and JTextArea as short, vertical lines
- Perform a task each interval
- Compound classes stored in an array are not accessible in selenium java
- How to avoid concurrent access to a resource?
- Why does processing goes slower on implementing try catch block in java?
- Redirect inside java interceptor
- Push toolbar content below statusbar
- Animation in Java on top of JPanel
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- Java Assign a Value to an array cell
Related Questions in MULTITHREADING
- new thread blocks main thread
- WPF MessageBox Cancel checkbox check
- How to avoid concurrent access to a resource?
- run oncomplete event in async
- Threading Segfault when reading members
- Function timeouts in C and thread
- How are multiple requests to Task.Run handled from a resource management standpoint?
- Acumatica perfomance with threads
- Wait and Notify in Java threads for a given interval
- Different behavior of async with Visual Studio 2013(Windows8.1) and GCC 4.9(Ubuntu14.10)
- How to return blocking queue to the right object?
- background thread using Task.Run
- deletion and cleanup of worker thread in Qt crashes
- Pipeline-like operation using TChan
- implementing in app purchase on android
Related Questions in VERT.X
- vertx deploy vertical after getting reply from event bus
- Unable to access request body using getBodyAsJson() in Vert.X 3.0.0
- Vertx 3 application logging from Javascript
- How to access gmail API?
- Vertx Eventbus not working in Java
- Verticles and uncaught exceptions
- Java non-blocking TLS PSK
- How to access GMail API from my own GMail?
- Using gRPC with Vert.x, netty dependency issue
- Websocket creation using sockjs-client/sockjs in angular2 webapp project
- Stubbing a void method with side effects
- Blocking code is executed in the one thread
- Match response handler with request in VertX
- Improve performance using Bcrypt in VertX
- Unable to get any configuration readings outside the ".listen()" method
Related Questions in SINGLE-THREADED
- When NOT to use database connection pooling in Java?
- How can CPU usage max out at 50% but not use one CPU effectively?
- How does JavaScript's Single Threaded Model handle time consuming tasks?
- Single Threaded MDB on Glassfish
- Single- vs. multi-threaded programming on a single core processor
- RabbitMQ in scalable nodejs Apps, How make a build well scalable app?
- Run all tests in same thread NUnit
- Corda FlowLogic Behaviour in a scenario - What is the relevance of threads here?
- Number of threads created is 12 but still runs only on one core of 12 core-CPU
- Get User info in WCF-service with [STAOperationBehavior] attribute
- Wcf Singleton with Single Thread
- Can we consider an requestAnimFrame a 'yield' on the application loop to allow the event loop to process?
- netty 4; how to initialize client's connection from same thread synchronously
- Does Tokio have run_until_stalled equivalent?
- How to Capture Each New Millisecond Without Overwhelming the CPU
Related Questions in SINGLETHREADMODEL
- How to set node server to run different requests simultaneously?
- Initializing the COM library in apartment threaded mode in a thread with no message loop
- How vert.x is single threaded?
- (Servlets, Thread safety) Protecting the session and context state
- How can .NET Core compare to Node.js when it still has the context switch overhead?
- 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?
- Node JS multiple concurrent requests to backend API
- How to create a STA (Single Threaded apartment) control in VS2010
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 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.