简体   繁体   中英

Does a thread invoking, synchronized method, pre-empt another thread using same object but in a non synchronized manner?

In Java, Does a thread invoking, synchronized method, pre-empt another thread using same object but in a non synchronized manner?

Also, when a thread is invoking a synchronized method or synchronized block, does the thread explicitly owns the entire object?

In Java, Does a thread invoking, synchronized method, pre-empt another thread using same object but in a non synchronized manner?

No, one thread (assuming no data-races/race-conditions) knows nothing about what another thread is doing outside of synchronization.

Also, when a thread is invoking a synchronized method or synchronized block, does the thread explicitly owns the entire object?

If by own you mean mutual exclusion, than no, it only has ownership to synchronized regions.

First question: no

Second question cannot be answered, because "owned" is not well defined.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM