naved momin wrote:1. How can I make sure that my programe will take utilization of all the cores in any CPU ?(I Guess just creating multiple Threads will not solve this problem ?)
Find places in your program that can be parallelized, and you can submit them as tasks in an executor service. However, this is usually only useful for responsiveness of the program, and not necessarily for absolute speed, since there is an overhead in using multiple threads. Save this for big tasks, such as handling requests or transactions from remote clients, and not for nano-optimizations such as performing a merge-sort concurrently.
2. How can I make sure that my programe will take minimum memory ?
Just program neatly and in a simple manner, and memory usually takes care of itself. If you jump through silly hoops to increase performance (either memory use or speed), you usually end up hurting performance instead. Make sure that variables you don't use anymore go out of scope, and you don't accidentally save them somewhere. Breaking up big methods in smaller ones that do simple things helps with this.
3. And finally how to write a robust more secure code ? (which is tough for other peoples to break)
Write simple methods with a clear contract, enforce the requirements in the method (by throwing exceptions when necessary) and program defensively.
You should read Jushua Bloch's
Effective Java to learn a lot about writing good clean code.