I’m using this class and I’m wondering whether it’s thread safe: https://docs.spring.io/spring-amqp/api/org/springframework/amqp/support/converter/Jackson2JsonMessageConverter.html The docs don’t make any claims about this. I skipped through the code and found no signs it’s not thread-safe. It’s using an ObjectMapper internally, which is thread-safe according to docs: https://fasterxml.github.io/jackson-databind/javadoc/2.13/com/fasterxml/jackson/databind/ObjectMapper.html Mapper instances are fully thread-safe provided that ALL configuration of the instance occurs before ANY read
Tag: thread-safety
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
Clock thread in Java
I have been studying about Java Thread recently. I created this simple clock that will display how many seconds have passed. It looked like this Here is the code for the application above (including 2 classes: Main and ClockPanel) The problem is: if i remove the line System.out.println() (as i commented in the code above), the clock will not run.
Getting IllegalMonitorStateException while printing arraylist using threads
I am trying to print out the content of arraylist using 2 threads, my main goal is to make threads read arraylist in a synchronized way and print its content. Eventhough I use synchronized block, I still am getting IllegalMonitorStateException. I know this is a basic question but I can not get it working, pardon me. And here is myThread
Does a mutable Java object equal itself? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I was thinking about mutable objects and how they’re weird (but very cool). Question: can a mutable object not equal itself? Only caveat here is
Java mmap MappedByteBuffer
Let’s say I’ve mapped a memory region [0, 1000] and now I have MappedByteBuffer. Can I read and write to this buffer from multiple threads at the same time without locking, assuming that each thread accesses different part of the buffer for exp. T1 [0, 500), T2 [500, 1000]? If the above is true, is it possible to determine whether
If a method is synchronized, do the called methods also have to be synchronized?
If a method is synchronized, do the called methods also have to be synchronized? What is correct in the following example? Answer If a method is synchronized, do the called methods also have to be synchronized? No. There is no general reason that you need to call a synchronized method from another synchronized method. Assuming that the methods are synchronizing
Can a java thread waiting with wait() ,notify itself?
I came across the following e example to implement custom suspend and wait from some website. I am more concerned about the ob1.mysuspend() and ob1.myresume() calls. When my suspend is called then ob1 will be placed into the blocking queue associated with the runnable object it is using. When ob1 calls myresume, then how does it work as ob1 is
Java HttpHandler waiting for CompletableFuture
I got the following code The idea is that I make a call to another client for some information, wait for his response, and then present the data that has been received and processed. But i am looking for a way to avoid the need for Thread.sleep to avoid possible issues with other code in the system. Is there another
How can I guarantee a thread is safely unlocking a lock upon termination, while all methods already handle it?
A server project, might run for very long time and create many threads. In the following code I ask myself do i have to protect the lock somehow in addition to an overall try catch in method setData(MyData data): note: assuming its thread-safe, i am not really familiar with other reasons or natural disasters that may cause thread termination, like