Copyright (c) SEMM NL All rights reserved.
Author : Paul Hamaker. Part of JavaLessons.com
Not only methods can be synchronized.
If you want exclusive use of a Vector and be sure that no other thread can call Vector's synchronized methods, like addElement, while you're using it, code :
So, by specifying a reference to some object as synchronized, you can exclude other threads from accessing that object at that time.
This applies only to synchronized methods/blocks. Plain methods can be called by any thread, any time.
Local variables are created on the fly, inside a method, so each thread traversing that method gets its own copies of these variables !
If you want a thread to get more processing time than others, you can request
someTask.setPriority ( Thread.MAX_PRIORITY ) ;
Thread.MAX_PRIORITY = 10
Default : Thread.NORM_PRIORITY = 5
Thread.MIN_PRIORITY = 1
DON'T use threads in EJB !
Using threads in combination with Swing sometimes requires special measures.
stop, suspend and resume
methods have been deprecated, so you mustn't use them anymore.