Results 1 to 9 of 9
Thread: Thread Threat
- 09-19-2011, 07:05 AM #1
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
- 09-19-2011, 09:41 AM #2
Re: Thread Threat
Hi. Java works with thread through native OS functions. Just read about how to realization this functions in special OS.
Regard.
PS What is mean Balagurusamy? :)Skype: petrarsentev
http://TrackStudio.com
- 09-19-2011, 10:23 AM #3
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
- 09-27-2011, 07:16 AM #4
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
Re: Thread Threat
give me some real world examples of threads utility .
- 09-27-2011, 03:05 PM #5
Re: Thread Threat
Reading data from the internet while responding to a user's requests on a GUI
- 09-27-2011, 03:48 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Thread Threat
Riffing off Norm's post, threads are used by most every web server.
One thread per request coming in (up to some thread limit).
- 10-07-2011, 11:34 AM #7
Member
- Join Date
- Aug 2011
- Location
- INDIA
- Posts
- 64
- Rep Power
- 0
Re: Thread Threat
sometimes i have seen we dint even inherit thread class nor interface runnable
just by this statement ,programme runs
Thread th =new thread();
i dint understand why this happens?
- 10-07-2011, 04:38 PM #8
Re: Thread Threat
What is the code in the thread class? Does it extend the Thread class? Remember java is case sensitive, so I'm talking about 2 different classes.Java Code:Thread th =new thread();
- 10-16-2011, 09:15 PM #9
Member
- Join Date
- Oct 2011
- Posts
- 65
- Rep Power
- 0
Re: Thread Threat
I think thread() class is coded by programmer else that is wrong. Every thing is object in java. implementation is wrong but you can make smthg like that
ex:
public class myThread extends Thread{
public myThread(){
super ();
}
} // by this way you can add some other methods in Thread class and improve the class.
I will simply explain thread in java.
Thread is kind of process that runs the program.
First difference of process and thread is important
-process is a thread as well but you can not use process in process.
-You can use threads in process.
You can call process as main thread. In C that is a little different. (In C you use fork() to create thread .....)
DataStructure are like tree;
Process is the root;
Threads are child or node;
I can not explain structure of thread You can look in google or book;
Second : In java when you run a program , process begins;
In Process you can create threads that can make some independant work
Simple example from this web site:> When you are writing reply you can see that Auto-Saved. Just like MS Word when you are writing in word program it automaticly saves content of word page. That means there are at least 2 thread (There are more than 2 thread) 1 thread handles writing second thread saves content when you are writing.
1 thread only manages 1 job at the same time. You can not use 1 thread to do 2 works in sample period of time so you create second thread to handle that issue.
----------------------------------------END OF THREAD PURPOSE------------------------
Thread th=new Thread();
// your quesiton:> Thread is class you can get instance of Thread class but you have to make some modifications;
Ex:
Thread th=new Thread(){@Override public void run(){ System.out.println("HI");// implement some code for thread will deal}};
th.start();
System.out.println("HELLO");
If you write this code to somewhere in method It will print HI and at the same time your program handles other jobs.
I will mention about instance; // Just think that when you get instance of class (new Thread()), you creates a special memory for that class (Classes have Fields(int a,String b,.....) ,METHODS,MEMBERS..... as you know); For example: if you do not get instance, you can not use that classes' attributes(Fields); I will not explain static,dynamic variables
Not every class can be got instance by user; //some class types : abstract class, Enum , interface, // you have to read them
but all public classes can be got instance by user. //Even if they have private constructors .... I will just skip this explanation
//my thoughts
At last main class :>> If you know about nested class, main is nested class and anonymous class type.
public static void main(String [] args) // First I will explain main properties.
First it has to be public to access
Second it has to be static because static variables or classes are created in runtime. //I do not know in java but static variables can be kept to cache for improve performance
static variables can be accessed from every where // GLOBAL Variables
Third if you write a programing language you need a specific class that you will need when runing program //Like in C, main is special class.
String []args // if your program needs input from outside you can use it
main thread is a main process of java --> As I said in above, Process is main thread. Root of java threads
// For more information you search JVM , JIT , .....
Similar Threads
-
Main Thread not waiting for grand child thread to finish
By prashanthn in forum Threads and SynchronizationReplies: 3Last Post: 06-07-2011, 09:26 AM -
Difference between Thread.yield() and Thread.sleep() methods
By Nageswara Rao Mothukuri in forum New To JavaReplies: 12Last Post: 07-30-2010, 05:37 PM -
Trigger main thread method from secondary thread?
By DigitalMan in forum Threads and SynchronizationReplies: 8Last Post: 01-26-2010, 02:13 AM -
If JNI thread call the java object in another thread, it will crash.
By skaterxu in forum Advanced JavaReplies: 0Last Post: 01-28-2008, 07:02 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks