Skip to content
Advertisement

Tag: concurrency

java concurrency vs parallelism

I know the difference between the two clearly. Concurrency is performing multiple tasks alternately, while parallelism is performing multiple tasks at once. However, there is confusion in this code because a certain instructor has a different opinion than me. Here is code: I thought that running this code on multiple cores would run with parallelism, not concurrency, the instructor says

Thread-safety of int field in Java

If class has field with int type (not Atomic Integer and without volatile keyword) and all access to this field happens under read/write locks – will this field thread-safe in this case? Or in some moment some thread can see not real value of this field but something from cache? Answer Get answer from @pveentjer in comments under question: It

Is replacing one java object reference with another considered thread safe, or are there potential synchronicity issues I’m overlooking?

I’m rolling my own simple caching solution to improve the UX of a lengthy lookup. The basic outline is that I have a class handling all accountId lookups, and another class called AccountListCache with two variables: a timestamp indicating when it was created, and a List object containing a whole bunch of accountId objects. When the lookup is invoked, that

How to use Throughput Shaping Timer from JMETER API using Java code?

enter image description here 1: https://i.stack.imgur.com/sRx3n.jpg**strong text**## I am trying to write the Java program to get the input something like this for multiple rows and process it by creating concurrency thread group which can generate number of threads from tstfeedback function and complete the execution.enter image description here Answer Here is an example of creating an empty Test Plan

Can another thread see an effectively immutable object in an inconsistent state if it is published with a volatile reference?

According to Java Concurrency in Action if we have the following class: and we initialise an instance of this class and publish it in a non-safe way (through a simple public field for example), then the assertCorrectness() might indeed throw an AssertionError, if called from another thread. In other words, this means that some another thread might see an up-to-date

Advertisement