Search Results

Search found 2076 results on 84 pages for 'as keyword'.

Page 16/84 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • using volatile keyword

    - by sap
    As i understand, if we declare a variable as volatile, then it will not be stored in the local cache. Whenever thread are updating the values, it is updated to the main memory. So, other threads can access the updated value. But in the following program both volatile and non-volatile variables are displaying same value. The volatile variable is not updated for the second thread. Can anybody plz explain this why testValue is not changed. class ExampleThread extends Thread { private int testValue1; private volatile int testValue; public ExampleThread(String str){ super(str); } public void run() { if (getName().equals("Thread 1 ")) { testValue = 10; testValue1= 10; System.out.println( "Thread 1 testValue1 : " + testValue1); System.out.println( "Thread 1 testValue : " + testValue); } if (getName().equals("Thread 2 ")) { System.out.println( "Thread 2 testValue1 : " + testValue1); System.out.println( "Thread 2 testValue : " + testValue); } } } public class VolatileExample { public static void main(String args[]) { new ExampleThread("Thread 1 ").start(); new ExampleThread("Thread 2 ").start(); } } output: Thread 1 testValue1 : 10 Thread 1 testValue : 10 Thread 2 testValue1 : 0 Thread 2 testValue : 0

    Read the article

  • Tag/Keyword based recommendation

    - by Hellnar
    Hello I am wondering what algorithm would be clever to use for a tag driven e-commerce enviroment: Each item has several tags. IE: Item name: "Metallica - Black Album CD", Tags: "metallica", "black-album", "rock", "music" Each user has several tags and friends(other users) bound to them. IE: Username: "testguy", Interests: "python", "rock", "metal", "computer-science" Friends: "testguy2", "testguy3" I need to generate recommendations to such users by checking their interest tags and generating recommendations in a sophisticated way. Ideas: A Hybrid recommendation algorithm can be used as each user has friends.(mixture of collaborative + context based recommendations). Maybe using user tags, similar users (peers) can be found to generate recommendations. Maybe directly matching tags between users and items via tags. Any suggestion is welcome. Any python based library is also welcome as I will be doing this experimental engine on python language.

    Read the article

  • volatile keyword seems to be useless?

    - by Finbarr
    import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; public class Main implements Runnable { private final CountDownLatch cdl1 = new CountDownLatch(NUM_THREADS); private volatile int bar = 0; private AtomicInteger count = new AtomicInteger(0); private static final int NUM_THREADS = 25; public static void main(String[] args) { Main main = new Main(); for(int i = 0; i < NUM_THREADS; i++) new Thread(main).start(); } public void run() { int i = count.incrementAndGet(); cdl1.countDown(); try { cdl1.await(); } catch (InterruptedException e1) { e1.printStackTrace(); } bar = i; if(bar != i) System.out.println("Bar not equal to i"); else System.out.println("Bar equal to i"); } } Each Thread enters the run method and acquires a unique, thread confined, int variable i by getting a value from the AtomicInteger called count. Each Thread then awaits the CountDownLatch called cdl1 (when the last Thread reaches the latch, all Threads are released). When the latch is released each thread attempts to assign their confined i value to the shared, volatile, int called bar. I would expect every Thread except one to print out "Bar not equal to i", but every Thread prints "Bar equal to i". Eh, wtf does volatile actually do if not this?

    Read the article

  • Static classes in PHP via abstract keyword?

    - by Boldewyn
    According to the PHP manual, a class like this: abstract class Example {} cannot be instantiated. If I need a class without instance, e.g. for a registry pattern: class Registry {} // and later: echo Registry::$someValue; would it be considered good style to simply declare the class as abstract? If not, what are the advantages of hiding the constructor as protected method compared to an abstract class? Rationale for asking: As far as I see it, it could a bit of feature abuse, since the manual refers to abstract classes more as like blueprints for later classes with instantiation possibility.

    Read the article

  • "dynamic" keyword and JSON data

    - by Peter Perhác
    An action method in my ASP.NET MVC2 application returns a JsonResult object and in my unit test I would like to check that the returned JSON object indeed contains the expected values. I tried this: 1. dynamic json = ((JsonResult)myActionResult).Data; 2. Assert.AreEqual(JsonMessagesHelper.ErrorLevel.ERROR.ToString(), json.ErrorLevel); But I get a RuntimeBinderException "'object' does not contain a definition for 'ErrorLevel'". However, when I place a breakpoint on line 2 and inspect the json dynamic variable (see picture below), it obviously does contain the ErrorLevel string and it has the expected value, so if the runtime binder wasn't playing funny the test would pass. What am I not getting? What am I doing wrong and how can I fix this? How can I make the assertion pass?

    Read the article

  • Syntax error in SWIG using __thread keyword

    - by user366838
    I am trying to make some code thread safe for use with pthreads. This code is written in C++, but is linked to using SWIG. g++ compiles this correctly, but when swig tries to create a wrapper, I get: fast_alloc.hh:109: Error: Syntax error in input(3) The original, unsafe code that compiles correctly is: static void *freeLists[Num_Buckets]; and the error occurs when I change it to: static __thread void *freeLists[Num_Buckets]; I have made other parts thread safe adding "__thread", for example, this works: static __thread unsigned newCount[Num_Buckets];

    Read the article

  • Jquery $().each method obscures 'this' keyword

    - by Jeff Fritz
    I am creating a Javascript object that contains a function that executes a jQuery each method like the following: function MyClass { Method1 = function(obj) { // Does something here } Method2 = function() { $(".SomeClass").each(function() { // 1 2 this.Method1(this); }); } } Which object is each THIS referring to? jQuery is referring to the item returned from the each iteration. However, I would like This[1] to refer to the containing class... How can I refer to the containing class from within the jQuery loop?

    Read the article

  • SEO google keyword position tools?

    - by Peterl86
    Hi guys, I want to check our google postions for several keywords every day and make a note in a spreadseet. At the moment, we have a student doing it but it's a rubbish job and it doesn't seem fair on them! Are there any tools available to automate this process? I have tried rankchecker by seobook.com, but although that should be exactly what im looking for when i set scheduled tasks in that, it doesnt work. Any tips would be appreciated, thanks! peter EDIT: Liam has suggested a Python script to do this, which unfortunately isnt something I'm very familiar with! If anyone knows of a good tutorial or something to help us with this, that would be brilliant. Update: Found a php script at seoscript.net which looks like a step in the right direction. But I cant get it to work! I get this error. Anyone more knowledgabe than me know how to fix that? I have PEAR installed. thanks again, Peter

    Read the article

  • Unable to create unmanaged object using new keyword in managed C++

    - by chair79
    Hi all, I've created a class with a boost::unordered_map as a member, Linkage.h #ifndef LINKAGE_H #define LINKAGE_H #include <boost/unordered_map.hpp> class Linkage { private: boost::unordered_map<int, int> m_IOMap; public: .... }; Linkage.cpp #include "stdafx.h" ... // methods and in the managed side of C++, I try to create the pointer of the obj: private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { Linkage* m_pLink = new Linkage(); ..... } However this produces errors: Error 4 error LNK2005: "private: static unsigned int const boost::detail::type_with_alignment_imp<4>::found" (?found@?$type_with_alignment_imp@$03@detail@boost@@$$Q0IB) already defined in Proj_Test.obj Linkage.obj ..... Error 7 fatal error LNK1169: one or more multiply defined symbols found Could anyone explain to me pls? Thanks.

    Read the article

  • Display virtual keyword asp.net for password

    - by Nicole
    Hi! I have a login page with an input of type "password" I would like to have a virtual keyboard to enter the password. I've searched and I found the jquery script for virtual keyboard. The code said to add this to my page $('input[type=password]').keyboard({ layout: "qwerty", customLayout: [["q w e r t y {bksp}", "Q W E R T Y {bksp}"], ["s a m p l e {shift}", "S A M P L E {shift}"], ["{accept} {space} {cancel}", "{accept} {space} {cancel}"]] }); but I cant make it work!!!! nothing happens when y set focus on my password control. Any suggestions?? thank you!! Nicole.

    Read the article

  • why must you provide the keyword const in operator overloads

    - by numerical25
    Just curious on why a param has to be a const in operation overloading CVector& CVector::operator= (const CVector& param) { x=param.x; y=param.y; return *this; } couldn't you have easily done something like this ?? CVector& CVector::operator= (CVector& param) //no const { x=param.x; y=param.y; return *this; } Isn't when something becomes a const, it is unchangeable for the remainder of the applications life ?? How does this differ in operation overloading ???

    Read the article

  • Help me clean up this crazy lambda with the out keyword

    - by Sarah Vessels
    My code looks ugly, and I know there's got to be a better way of doing what I'm doing: private delegate string doStuff( PasswordEncrypter encrypter, RSAPublicKey publicKey, string privateKey, out string salt ); private bool tryEncryptPassword( doStuff encryptPassword, out string errorMessage ) { ...get some variables... string encryptedPassword = encryptPassword(encrypter, publicKey, privateKey, out salt); ... } This stuff so far doesn't bother me. It's how I'm calling tryEncryptPassword that looks so ugly, and has duplication because I call it from two methods: public bool method1(out string errorMessage) { string rawPassword = "foo"; return tryEncryptPassword( (PasswordEncrypter encrypter, RSAPublicKey publicKey, string privateKey, out string salt) => encrypter.EncryptPasswordAndDoStuff( // Overload 1 rawPassword, publicKey, privateKey, out salt ), out errorMessage ); } public bool method2(SecureString unencryptedPassword, out string errorMessage) { return tryEncryptPassword( (PasswordEncrypter encrypter, RSAPublicKey publicKey, string privateKey, out string salt) => encrypter.EncryptPasswordAndDoStuff( // Overload 2 unencryptedPassword, publicKey, privateKey, out salt ), out errorMessage ); } Two parts to the ugliness: I have to explicitly list all the parameter types in the lambda expression because of the single out parameter. The two overloads of EncryptPasswordAndDoStuff take all the same parameters except for the first parameter, which can either be a string or a SecureString. So method1 and method2 are pretty much identical, they just call different overloads of EncryptPasswordAndDoStuff. Any suggestions? Edit: if I apply Jeff's suggestions, I do the following call in method1: return tryEncryptPassword( (encrypter, publicKey, privateKey) => { var result = new EncryptionResult(); string salt; result.EncryptedValue = encrypter.EncryptPasswordAndDoStuff( rawPassword, publicKey, privateKey, out salt ); result.Salt = salt; return result; }, out errorMessage ); Much the same call is made in method2, just with a different first value to EncryptPasswordAndDoStuff. This is an improvement, but it still seems like a lot of duplicated code.

    Read the article

  • virtual keyword in different scenarios

    - by Mahesh
    I figured out 2 different meanings for virtual based on the situation it is being used. If a baseClass has a function defined virtual, then the derivedClass is going to override the function. The baseClass::~baseClass() should be defined virtual, if there is any class derived from it. Here it means, the derived class destruction first takes place followed by base class destruction. Are there any other situations where virtual hold a different meaning ?

    Read the article

  • delphi "Invalid use of keyword" in TQuery

    - by Baldric
    I'm trying to populate a TDBGrid with the results of the following TQuery against the file Journal.db: select * from Journal where Journal.where = "RainPump" I've tried both Journal."Where" and Journal.[Where] to no avail. I've also tried: select Journal.[Where] as "Location" - with the same result. Journal.db is a file created by a third party and I am unable to change the field names. The problem is that the field I'm interested in is called 'where' and understandably causes the above error. How do I reference this field without causing the BDE (presumably) to explode?

    Read the article

  • Is it good to use same keyword for multiple pages in one domain?

    - by Phanen
    Hi, I want to know after Google recent updates, will it be good opt to use same keywords for multiple pages? Say- my keyword is "driver update" and I have a folder "HP" in website. Hp has lots of models like HP Elitebook, HP Envy, HP Mini, HP Pavilion and much more. HP Elitebook has many versions like HP Elitebook 2530p, HP Elitebook 2730p, HP Elitebook 8530w. Now should I create pages like "Driver update in HP Elitebook 2530p" , "Driver update in HP Elitebook 2730p", "Driver update in P Elitebook 8530w" or a single page "Driver update in HP Elitebook"? Which one will be the best option for better SE ranking- " single page or multiple pages using same keyword for different model versions" ?

    Read the article

  • Jquery-Different between event.target and this keyword?

    - by Jerry
    Hi all Got a quick and might be an newbie question. What is the different between event.target and this? let's say I have $("test").click(function(e){ $thisEventOb=e.target; $this=this; alert($thisEventObj); alert($this); }); I know the alert will pop different value. Anyone could explain the difference? Thanks a million.

    Read the article

  • How to use AS keyword in MySql ?

    - by karthik
    In the below SP i will be getting result in One single column. How can i name the column of the output ? DELIMITER $$ DROP PROCEDURE IF EXISTS `InsGen` $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `InsGen` ( in_db varchar(20), in_table varchar(20), in_ColumnName varchar(20), in_ColumnValue varchar(20) ) BEGIN declare Whrs varchar(500); declare Sels varchar(500); declare Inserts varchar(2000); declare tablename varchar(20); declare ColName varchar(20); set tablename=in_table; # Comma separated column names - used for Select select group_concat(concat('concat(\'"\',','ifnull(',column_name,','''')',',\'"\')')) INTO @Sels from information_schema.columns where table_schema=in_db and table_name=tablename; # Comma separated column names - used for Group By select group_concat('`',column_name,'`') INTO @Whrs from information_schema.columns where table_schema=in_db and table_name=tablename; #Main Select Statement for fetching comma separated table values set @Inserts=concat("select concat('insert into ", in_db,".",tablename," values(',concat_ws(',',",@Sels,"),');') from ", in_db,".",tablename, " where ", in_ColumnName, " = " , in_ColumnValue, " group by ",@Whrs, ";"); PREPARE Inserts FROM @Inserts; EXECUTE Inserts; END $$ DELIMITER ;

    Read the article

  • casting vs using the 'as' keyword in the CLR

    - by Frank V
    I'm learning about design patterns and because of that I've ended using a lot of interfaces. One of my "goals" is to program to an interface, not an implementation. What I've found is that I'm doing a lot of casting or object type conversion. What I'd like to know is if there is a difference between these two methods of conversion: public interface IMyInterface { void AMethod(); } public class MyClass : IMyInterface { public void AMethod() { //Do work } // other helper methods.... } public class Implementation { IMyInterface _MyObj; MyClass _myCls1; MyClass _myCls2; public Implementation() { _MyObj = new MyClass(); // What is the difference here: _myCls1 = (MyClass)_MyObj; _myCls2 = (_MyObj as MyClass); } } If there is a difference, is there a cost difference or how does this affect my program? Hopefully this makes sense. Sorry for the bad example; it is all I could think of... Update: What is "in general" the preferred method? (I had a question similar to this posted in the 'answers'. I moved it up here at the suggestion of Michael Haren. Also, I want to thank everyone who's provided insight and perspective on my question.

    Read the article

  • java - question about thread abortion and deadlock - volatile keyword

    - by Tiyoal
    Hello all, I am having some troubles to understand how I have to stop a running thread. I'll try to explain it by example. Assume the following class: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; interrupt(); } } Assume the thread is running and the following statement is evaluated to true: while (someObject.someCondition() == false && running) Then, another thread calls MyThread.halt(). Eventhough this function sets 'running' to false (which is a volatile boolean) and interrupts the thread, the following statement is still executed: someObject.wait(); We have a deadlock. The thread will never be halted. Then I came up with this, but I am not sure if it is correct: public class MyThread extends Thread { protected volatile boolean running = true; public void run() { while (running) { synchronized (someObject) { while (someObject.someCondition() == false && running) { try { someObject.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // do something useful with someObject } } } public void halt() { running = false; synchronized(someObject) { interrupt(); } } } Is this correct? Is this the most common way to do this? This seems like an obvious question, but I fail to come up with a solution. Thanks a lot for your help.

    Read the article

  • From xcode not able to execute DISTINCT keyword for sqlite

    - by mac
    -(void) readProductsFromDatabase { // Setup the database object sqlite3 *database; // Init the animals Array products = [[NSMutableArray alloc] init]; // Open the database from the users filessytem if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { NSLog(@"db opened"); // Setup the SQL Statement and compile it for faster access const char *sqlStatement = "SELECT DISTINCT productname FROM iphone "; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { // Loop through the results and add them to the feeds array while(sqlite3_step(compiledStatement) == SQLITE_ROW) { NSLog(@"inside sqlite3 prepare"); // Read the data from the result row NSString *aName = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; } } // Release the compiled statement from memory sqlite3_finalize(compiledStatement); } sqlite3_close(database); } My problem is const char *sqlStatement = "SELECT DISTINCT productname FROM iphone "; This line not executing ,i am using sqlite3, thanks in advance,

    Read the article

  • Live() keyword not working on load with dynamic html images

    - by Sara Chipps
    I have images being dynamically added to a page, I don't seem to be able to get the 'load' event working dynamically with live(). This is the code I currently have: $('#largeImg' + nextUniqueItemID).hide(); $('#largeImg' + nextUniqueItemID).live('load' , function() { $('#loader' + nextUniqueItemID).hide(); $('#largeImg' + nextUniqueItemID).show(); }); with '#largeImg' + nextUniqueItemID being an image that was added to the page earlier in the function and '#largeImg' + nextUniqueItemID being a loading image. I feel as if I may be misusing "live" as it doesn't really need a listener but to trigger the event immediately.

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >