Ikpefua Jacob-Obinyan wrote: the yield() method "tends" to make the currently running thread head back to a runnable state to allow other threads of the SAME priority get a turn.
To help ensure that other threads in the VM get a turn to run on the processor, a thread can voluntarily give up its turn early. If a thread invokes the static method Thread.yield(), the thread scheduler will swap it off the processor and allow another thread to run. It is likely (but not guaranteed) that only threads having a priority equal to or greater than the one that yielded control will be considered by the thread scheduler.
Loose coupling: your classes must be independent from each other. Otherwise
your class could 'break' because of another 6,7... 10 classes that are
strongly related to it. With better coupling your class doesn't need many
other classes and your application is bit stronger.
High Cohesion - that's the entity of a class or method. You shouldn't
develop a method that acts like a whole big application (for example, all of
your program in a method). When an exception comes out, it's harder to find
the problem and look over thousands of lines code. When you keep strong
cohesion, your methods act like 1 simple organism and it's easier to look
over them.
Strong cohesion: System.out.println(message);
Simple operation, gets the information and send it to the console.
Bad cohesion: a method that executes connecting to Internet, downloading
information, putting it into a database, changing details, exporting,
printing, uploading back to Internet. All of this activities in a method.
How many errors could occur here? ;)
Encapsulation, in my opinion, is strongly related to data abstraction. They
both form a mechanism like a Black Box (airplanes` black boxes) or a clock -
you just see the display, but you don't have an idea what's hidden inside
and how it works. And you don't care. All data and operations are collected
in your class. Good practise is hiding the details: all fields private and
usage of getters and setters to gain access to your fields. That's how you
can implement complex logic in your getters/setters, you can restrict access
(read-only, write-only or both, or none). Finally, you show users only the
information that he/she needs. Remember the example with the clock- you
don't mind if the mechanism gets replaced, if you see this display, working
the same way.
Make private fields, public/protected getters and setters; private methods
for internal algorithms that are no interest for the user; public methods
that user can use. If you update your app and change your logic, it should
be invisible for the user- he just have to use the same algorithm and a set
of operations.