aspose file tools*
The moose likes Beginning Java and the fly likes Get variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Get variable" Watch "Get variable" New topic
Author

Get variable

Juan Manuel Alberto de los Santos
Ranch Hand

Joined: Jun 26, 2008
Posts: 48


thanks
[ August 07, 2008: Message edited by: Juan Manuel Alberto de los Santos ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You can't, not as the code is written. If "number" were an instance variable instead of a local variable, then it would be accessible:


There's potentially another problem: the variable "number" is being accessed by two different threads, and that can lead to problems with the two threads not seeing the same value for the variable. I believe that in this case, it's OK because of the call to join() and the synchronization that it involves. Anyone disagree?


[Jess in Action][AskingGoodQuestions]
Juan Manuel Alberto de los Santos
Ranch Hand

Joined: Jun 26, 2008
Posts: 48
your solution works perfectly for what i wanted !

the join() method is the key here, otherwise, i got a 0 (because it reads the variable before the run() completes)

thanks !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get variable
 
Similar Threads
Variable Arguments
Retrieving a value ..
Passing value from one method to the next
difference between a class variable and local method variable with an example
Doubt with static initializers