Can an body explain alternate way to achieve the threadsafe without using the synchronization at method level block level?
public synchronized int disp()
{
}
or
public int disp()
{
Synchronized
{}
}
You could just use a single thread, of course.
You can design your application to avoid sharing mutable state, so that methods are inherently threadsafe.
You can use synchronized library collections.
You can use threadsafe queues to communicate between threads (Concurrent Queues).
It rather depends on what you are trying to achieve...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With