Random Name Generator: Android

Today i needed a name generator so i wrote one myself (i didn’t like the existing ones i found via Google. Here is the test code i used:

It produces names like:
I also added constructors for complete customization of the generate process. Here is the code:


Comment Please.Rolling on the floor laughing

10 Rules Every Android Programmer Should Know

I’ve now read a few interesting things that you should consider when programming Android in order to ensure as much performance as possible:

  1. As rarely as possible allocate memory
  2. Possible use etc but no integer int.
  3. Temporary return values ​​to avoid if possible! Strings that are used once and then return to the no longer needed brakes, the system unnecessarily. Rather the operation on the string to move the method itself.
  4. Multidimensional arrays can be simulated by one dimensional. Rumgetrickse for me a bit too much at the expense of readability ..
  5. Virtual methods instead of interface methods (eg, not using hashmap Map)
  6. Static methods are much faster than virtual
  7. no getter and setter
  8. Instead of access to member variables, they should only pass to a local.
  9. Do not use enums but constants for the elements of enums
  10. Avoid use of floating point numbers as floating-point arithmetic must be simulates cumbersome.

    One has therefore to ensure the performance of a piece of code readability, reduce and rewrite in a few years, the unreadable code again.


The advantage of threading is the ability to create applications that use more than one thread of execution. For example, a process can have a user interface thread that manages interactions with the user and worker threads that perform other tasks while the user interface thread waits for user input.

This tutorial demonstrates various thread activities:

  • Creating and executing a thread
  • Synchronization of threads
  • Interaction between threads
  • Using a thread pool
  • Using a mutex object to protect a shared resource
  • See Threading Sample to download and build the sample files discussed in this tutorial.

    Sample Files


    Example 1: Creating, starting, and interacting between threads

    This example demonstrates how to create and start a thread, and shows the interaction between two threads running simultaneously within the same process. Note that you don’t have to stop or free the thread. This is done automatically by the .NET Framework common language runtime.

    The program begins by creating an object of type Alpha (oAlpha) and a thread (oThread) that references the Beta method of the Alpha class. The thread is then started. TheIsAlive property of the thread allows the program to wait until the thread is initialized (created, allocated, and so on). The main thread is accessed through Thread, and theSleep method tells the thread to give up its time slice and stop executing for a certain amount of milliseconds. The oThread is then stopped and joined. Joining a thread makes the main thread wait for it to die or for a specified time to expire (for more details, see Thread.Join Method). Finally, the program attempts to restart oThread, but fails because a thread cannot be restarted after it is stopped (aborted). For information on temporary cessation of execution, see Suspending Thread Execution.

    Example Output

    Example 2: Synchronizing two threads: a producer and a consumer

    The following example shows how synchronization can be accomplished using the C# lock keyword and the Pulse method of the Monitor object. The Pulse method notifies a thread in the waiting queue of a change in the object’s state (for more details on pulses, see the Monitor.Pulse Method).

    The example creates a Cell object that has two methods: ReadFromCell and WriteToCell. Two other objects are created from classes CellProd and CellCons; these objects both have a method ThreadRun whose job is to call ReadFromCell and WriteToCell. Synchronization is accomplished by waiting for “pulses” from the Monitor object, which come in order. That is, first an item is produced (the consumer at this point is waiting for a pulse), then a pulse occurs, then the consumer consumes the production (while the producer is waiting for a pulse), and so on.