Multithreading, synchronization methods and realize the difference between Error and Exception with contact
Others
2019-09-03 05:21:32
views: null
Multithreading, synchronization implementation?
- There are two ways to achieve thread:
- Thread class inheritance
- Implement Runnable
- There are two ways to achieve synchronization
- One is a method of synchronization: synchronizing method is to add the method returns back type synchronized, for example: public void synchronized methodName () {...}
- One is to use sync block: sync block is written directly: the synchronized (written here in a subject in need synchronization) {...}
Error and exception differences and relations
- Restoration of error that is not impossible, but a serious problem under very difficult circumstances. For example, out of memory, network failure. We can not count on the program can handle the situation.
- exception that a design or implementation issues. In other words, it means that if run properly, would not have happened. Program can capture these exceptions, and processing.
Origin www.cnblogs.com/zxfei/p/11449139.html