GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 339 of 921    Print  
Suppose If we have variable ' I ' in run method, If I can create one or more thread each thread will occupy a separate copy or same variable will be shared

  
Total Answers and Comments: 1 Last Update: August 02, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 02, 2007 05:53:25   #1  
sujatham Member Since: January 2006   Contribution: 142    

RE: Suppose If we have variable ' I ' in run method, I...

I we declare variable I  like  below,
volatile int I;
each thread  will occupy  a separate copy  of  variable I.

If we  declare a variable I like below,

int I;

each thread will share the same variable.


 
Is this answer useful? Yes | No

 Related Questions

A transient variable is a variable that may not be serialized. 
Latest Answer : I think that in this case 3 processes will be started because we are starting individual programs. If we are starting 2 or more tabs in IE then we are starting threads. Notepad is SDI, so it will not have multiple threads.So, I will stick to the processes ...

Objects that subclass the Observable class maintain a list of observers. When anObservable object is updated it invokes the update() method of each of its observers tonotify the observers that it has changed 
Latest Answer : Observer observe only those class which are Observable. ...

With respect to multithreading, synchronization is the capability to control the access ofmultiple threads to shared resources. Without synchronization, it is possible for onethread to modify a shared 
Latest Answer : Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time. In a practical point of view assume that two threads are trying to update bank balance at the same time!!! How we can solve this issue the answer is sychronization. ...

The setLayout() method is used to specify a container's layout. 

When a thread terminates its processing, it enters the dead state. 
Latest Answer : the thread enters the 'TERMINATED' state. at this point, the thread is not accessible ...

setBounds() 
Latest Answer : component.setBounds(-,-,-,-); ...

When a task invokes its yield() method, it returns to the ready state. When a task invokesits sleep() method, it returns to the waiting state. 
Latest Answer : yield method is mainly used to release the lock of resource and pull up in to steady state from wait pool. Sleep() will pull the thread to sleep for the given time. It will throws exception while trying to intrupt in b/w the sleep state ...

Garbage collection does not guarantee that a program will not run out of memory. It ispossible for programs to use up memory resources faster than they are garbage collected.It is also possible for programs 
Latest Answer : The object is eligible for garbage collection only if there is no strong reference to the object. An exception to this is island of references(where all objects point to each other).And you should never write your significant code in the object's finalise ...

An object's finalize() method cannot be invoked by the garbage collector while the objectis still reachable. However, an object's finalize() method may be invoked by otherobjects. 
Latest Answer : No, reachable obejcts can not be garbage collected ...

The readLine() method returns null when it has reached the end of a file. 
Latest Answer : readLine() method of BufferReader class returns String and when it reaches the end of file file it returns null. ...


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

What is Common Data Modeling Method

Common Data Modeling is one of the core considerations when setting up a business data warehouse. Any serious company wanting to have a data warehouse will have to be first serious about data models. Building a data model takes time and it is not unusual for companies to spend two to five years just
 

What happens when a variable is not initialized in main function?

When a variable is not initialized in main function it contains garbage value. This can be well seen from the example below main() { int x; printf(“%d”,x); z= sample() } sample() { printf(“Testing program”); } Output is   &n
 

What happens when a variable is not declared in function definition?

Generally in C program the function definition and calling takes the form as given below: main() { int x,y,z; z=sample(x,y); printf(“%d”,z); } sample(x1,y1) int x1,y1; { int z1; z1= x1 - y1; return(z1); } Here what happens is the values x, y gets passed to x1,y1
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

JavaScript Window Object Open Method Part 2

JavaScript Window Object Open Method Part 2 In this JavaScript tutorial you will learn about JavaScript Window Object Open Method features of window object open method scrollbars status titlebar toolbar top width innerHeight innerWidth outerHeight outerWidth and hotkeys mosgoogle center scrollbars S
 

JavaScript Window Object Open Method

JavaScript Window Object Open Method In this JavaScript tutorial you will learn about JavaScript Window Object Open Method features of window object open method channelmode directories dependent fullscreen screenX screenY height left location menubar resizable alwaysLowered alwaysRaised mosgoogle ce
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 





About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape