< H2 > the first case < H2 > package com.btmans.thread; public class TestSync implements Runnable{ int b = 100; public synchronized void m1() throws Exception{ b = 1000; Thread.sleep(5000); System.out.println("b=&q...
topic description while learning the knowledge of multithreading, the result of the following code is not the same as expected. I can t see what the problem is. Please take a look at it . sources of topics and their own ideas what I think is that ...
in the following figure, while thread An executes the synchronized method of obj, thread B can execute other non-synchronized methods of obj I have read several blogs on the Internet, and most of them say yes. But as I understand it, when thread A ...
recently read "Java concurrent programming practice, " in Section 4.4.1, there is an example: suppose we need a thread-safe List, that needs to provide us with an atomic "put-if-absent " operation. And two implementations are provided: A non-thread...
Object obj=new Object(); Object obj2=obj; synchronized(obj){} synchronized(obj2){} what if this is the case? Object obj=new Object(); synchronized(obj){} obj=new Object(); synchronized(obj){} ...