Java Reference
In-Depth Information
Listing4-17 introducesyoutotheThreadingAPIviaa main() methodthatdemon-
strates Runnable , Thread(Runnable
runnable) , currentThread() ,
getName() , and start() .
Listing 4-17. A pair of counting threads
class CountingThreads
{
public static void main(String[] args)
{
Runnable r = new Runnable()
{
@Override
public void run()
{
String
name
=
Thread.currentThread().getName();
int count = 0;
Search WWH ::




Custom Search