Also, it's really strange that the thread would do different things (multiply or add two numbers) depending on its priority. You'd normally not write a program that has a completely different function if the priority of a thread is different.
sukruthi dandasi wrote:in the program when the user enters number between 1-10 i.e priority.if the priority matches minimum priority it should perform product of two numbers and display and if matches maxmum priority it should perform addition operation.these have to be in run().
At the moment all you are doing is creating a Thread object and setting its priority. You never actually start the thread, nor do you tell the Thread that when it starts it should run the run method in your class.
You might want to read this tutorial and find out how to do these basic things before you worry about the details of exactly what your method does. See if you can just get a message to print out from your classes run method first.
sukruthi dandasi wrote:no its not working in run() .i am just able to enter input and i know that if the priority is set by setPriority() and in order to get that supposed to use getPriority().where should i implement that?
In your run method where you currently call getName would probably be a good place to try.
sukruthi dandasi wrote:I am trying a practice code on thread priorities...
Well, quite apart from the fact that you're using them for something that has nothing to do with what they were designed for, can I ask why?
I have to admit never having used them myself, but if they're anything like process ('nice') priorities in Unix, the basic rule of thumb is: Don't change them unless you really know what you're doing.
ie: It's something that's best left to experts.