<<< A synchronized method that increments an instance variable | Index | Object class methods for inter-thread communication >>> |
public void add( int value )
{
Thread ct = Thread.currentThread();
synchronized( ct )
{
// Inside critical section:
count += value;
}
}
For a complete program using synchronized blocks of code, see multithreading examples on CIS-257 samples page.
<<< A synchronized method that increments an instance variable | Index | Object class methods for inter-thread communication >>> |