Java Multithreading
Multithreading allows two parts of the
same program to run concurrently. In Java, the
Java Virtual Machine (JVM) allows an application to have multiple threads
of execution running concurrently independently. When a program contains
multiple threads then the CPU can switch between the two threads to execute them
at the same time. In case of Multithreading, if
more than one thread manipulates shared variables or objects at the same time,
corruption may result. Instance variables are shared between threads. If one is
modified by a thread, the change affects the other threads.
Java
enables you to synchronize threads by defining a synchronized method. A thread
that is inside a synchronized method prevents any other thread from calling
another synchronized method on the same object.
Read
more at
http:/www.roseindia.net/java/thread/SynchronizedThreads.shtml