when we create a thread like this

class Run implements Runnable{

    public void run(){

        //You code
class Helloworld{

    public static void main(String args[]){

        Thread t1=new Thread(new Run());
        Thread t2=new Thread(new Run());

in above code thread t1 and thread t2 is creating in main() method its mean that t1 and t2 is creating in main thread because every application is single threaded but I read many articles in which i read that threads is being created in process but in upper case thread is being created in main thread it is confusing for me and sorry for my bad english just understang it

Recommended Answers

All 5 Replies

The Oracle tutorials are very good... start here

please give your concept?????

The link I gave you is a very clear, very accurate answer. I can't do any better than that. Did you read it?

yes i read it but it is very difficult to understand for me because my english is not good so please you tell me

I'll try... (watch carefully for "thread" vs "Thread")

A normal Java program runs in a single OS process. It has one or more threads that all share the process's resources. Your program starts running in a "main" thread, and from that thread you can start other threads, and other Java classes (eg Swing) can also start threads for you, and those threads can start other threads...

In the Java language, all those threads are represented by Thread objects - instances of the Thread class. You use the methods of the Thread class to query or control the execution of the programs' threads.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.