Tampilkan postingan dengan label thread. Tampilkan semua postingan
Tampilkan postingan dengan label thread. Tampilkan semua postingan

What is the difference between Services, Thread and an AsyncTask in Android?

Posted by Unknown Senin, 21 Oktober 2013 0 komentar
Thread Example n ANDROID -- Timer Thread Example
Non Runnable States in Multithreading - Different states while thread is in runnable states
What is a thread in java ?
How to write interfaces in java or Android?
More on Android ?

Service is like an Activity but has no interface. Probably if you want to fetch the weather for example you won’t create a blank activity for it, for this you will use a Service.

A Thread is a Thread, probably you already know it from other part. You need to know that you cannot update UI from a Thread. You need to use a Handler for this, but read further.

An AsyncTask is an intelligent Thread that is advised to be used. Intelligent as it can help with it’s methods, and there are two methods that run on UI thread, which is good to update UI components.

Baca Selengkapnya ....

Non Runnable States in Multithreading - Different states while thread is in runnable states

Posted by Unknown Senin, 03 Juni 2013 0 komentar
See more basics of thread in java here :
What is thread in java ?
The different states while thread is in runnable states are given below :
Sleeping States :
  •  may be alive, but not running
  •  may return to runnable state
  •  stop running for an amount of time 
Waiting for Notifications :
  •  wait for notification from other 
  •  send to runnable after notified thread
Blocked on I/O :
  • after availability of resource sends to runnable
Blocked for Joint Completion :
  • waiting for completion of another thread
Blocked for Lock Acquistion :
  • Come to this state because of  waiting to acquire the lock of an object.

Baca Selengkapnya ....

What is a thread in java ?

Posted by Unknown 0 komentar
see more post :
Non Runnable States in Multithreading - Different states while thread is in runnable states

A thread is a lightweight process.While dealing with one thread called single thread and with more thread called multi thread.

Main Thread :
                     
When a standalone application is running it is in main thread. What created inside is called  child thread.

Life Cycle Of Thread or States Of Thread :
     
           New State:
                       
When it is created and is when the thread is not alive ie, before start( ).

           Runnable (ready to run) State:
                        
After invoking start( ) it goes to runnable state.
                        Can return to this state after running, waiting, sleeping or back from blocked state.

           Running State:
                        
This state is at executing state.
         
           Dead State:
                        
This state begins when run( ) methods completes, from here it will never run again.

           Blocked State:
                        
A thread can enter in this state because of waiting the resources that are hold by another
                        thread.                            



Baca Selengkapnya ....

Blinking TextView - Two Methods

Posted by Unknown Rabu, 23 Januari 2013 0 komentar
METHOD 1

private void blink(){
final Handler handler = new Handler();
new Thread(new Runnable() {
public void run() {
int timeToBlink = 600; //in milissegunds
try
{
Thread.sleep(timeToBlink);
}catch (Exception e)
{

}handler.post(new Runnable()
{
public void run()
{
TextView txt = (TextView)findViewById(R.id.usage);
if(txt.getVisibility() == View.VISIBLE)
{
txt.setVisibility(View.INVISIBLE);
}else
{
txt.setVisibility(View.VISIBLE);
}
blink();
}
});
}
}).start();
}
METHOD 2

TextView myText = (TextView) findViewById(R.id.usage );
Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(50);
//You can manage the time of the blink with this parameter
anim.setStartOffset(20);
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(Animation.INFINITE);
myText.startAnimation(anim);

Baca Selengkapnya ....
Trik SEO Terbaru support Online Shop Baju Wanita - Original design by Bamz | Copyright of android populer.