I like to present some examples when describing any technical aspect. That's make it easier to understand. Today I am going to describe concurrency and parallelism - the differences between them and the similarities they share.
"When work, commitment, and pleasure all become one and you reach that deep well where passion lives, nothing is impossible." --Nancy Coey
Showing posts with label concurrency. Show all posts
Showing posts with label concurrency. Show all posts
Tuesday, May 31, 2016
Monday, April 27, 2015
Concurrent video stream processing in Java
Some time ago I was asked how to deal with video stream processing. The problem was quite simple. We have sequential input of video frames. Each frame must be processed, e.g. some filter must be applied. The trick is to utilize multiple cores to process these video frames. The output should contain processed video frames in correct order. I proposed one solution.
Wednesday, August 20, 2014
Java volatile keyword by example
Volatile keyword seems to be a little bit enigmatic at first glance. It is rather rare to see that keyword on a daily basis. How does it work? What effect can it have on the program execution?
Saturday, July 27, 2013
Contextual session-local Hibernate interceptor with Spring
Hibernate interceptor can be used for various purposes, e.g. audit trail, simple logging of persistent operations. However, we should have on our minds the fact that Hibernate SessionFactory level interceptor has to be implemented in a thread-safe manner, because it will be shared among all of the sessions. Is there any way to implement the interceptor with single-thread programming model?
Saturday, July 6, 2013
EJB vs. Spring thread safety
EJB and Spring are capable of providing ecosystem for the implementation of business services. EJB is more specific in its purpose whereas Spring brings us a great deal of flexibility. Can the freedom of Spring be dangerous?
Sunday, May 5, 2013
Simplification with intrinsic locking
When we deal with concurrency we use
'synchronized' keyword or we leverage the power of java.util.concurrent
(JUC) stuff in order to tame our threads. Both of the methods have
advantages and disadvantages. I would like to focus on one particular advantage of intrinsic locking.
Saturday, April 20, 2013
Database deadlock example
Some time ago I wrote about deadlock in Java language. However the problem of a deadlock can also appear in a database. The transactions are just the analogues of threads. Is a database able to recover from a deadlock? Let's check this out!
Saturday, April 13, 2013
Simple deadlock example - jstack to the rescue
The most popular deadlock example is about acquiring two different locks in the opposite order by two different threads. However it can be tricky to obtain deadlock in that way because we must encounter unlucky timings of the threads. I created a piece of code that is very likely to result in a deadlock.
Friday, March 15, 2013
Are interceptors similar to EJBs?
Being inspired by the blog entry and my current activity at work, I decided to present the behaviour of interceptors. Do they share something more with EJBs? Let's check it out!
Saturday, February 23, 2013
Injecting Stateful Session Bean into servlet
The advent of DI frameworks makes it natural to annotate a field with @EJB or @Inject and let the framework resolve the dependency for us. It can be that simple but sometimes something can behave incorrectly.
Tuesday, February 12, 2013
The frightening and shocking history of concurrency
Some time ago I was a participant of the Java conference. That time one of the speaker said that about 80-90% (I do not remember the exact value) of multi threaded code was synchronized wrongly and the rest of the code had not yet been proven to be synchronized wrongly.
Sunday, February 3, 2013
I am optimistic... exception!
Java EE applications usually handle many concurrent users. This means that there must exist some strategies that keep the data consistent in case of concurrent modification of the same database row (entity). JPA2 defines two types of locking, namely Optimistic Locking (OL) and Pessimistic Locking (PL).
Subscribe to:
Posts
(
Atom
)