Posts

multithreading - Java - is volatile required with synchronized? -

in following simple scenario: class { int x; object lock; ... public void method(){ synchronized(lock){ // modify/read x , act upon value } } } does x need volatile? know synchronized guarantees atomicity, not sure visibility though... lock -> modify -> unlock -> lock guarantee, after second lock value of x "fresh"? no not, synchronised has memory barrier inserted after it, threads see update current thread performs, taking account other threads synchronise on same lock. volatile, synchronised has memory barriers attached - depending on cpu store/load/full barrier ensures update 1 thread visible other(s). i assume performed cpu cache invalidation . edit i've read, store buffers flushed cpu cache, , how visibility achieved.

add library from Git to Android Studio -

i know must pretty basic question, i'm new android studio , gradle , , can't find up-to-date info on this. i'm trying add library project: android-segmented-control . it doesn't can add build.gradle file (correct?). i'd way, of course, , not download project if possible. if need download project, how link existing project? again, haven't been able find current describes process android studio 0.5.3 thanks @thomas bouron hint ! have pushed library maven center, need add following dependency build.gradle . dependencies { compile 'info.hoang8f:android-segmented:1.0.0' } (a little late @workinafishbowl may helpful others.).

Grails: Data is updated when try to sort a list -

i have been facing situation following code block has been behaving in strange manner. in following code snippet, when trying sort activity list of case work flow in taglib, perform db update instead of sorting data out. updates version of workflow row. can please suggest me missing anything? quick highly appreciated. taglib: class caseformtaglib { static namespace = 'caseform' def caseform = { attr, body -> def caseworkflow = caseworkflow.read(attr.workflowid) //line causing issue def activitylist = caseworkflow?.sortedactivitylist } } domain: class caseworkflow { list caseactivitylist static hasmany = [caseactivitylist: caseactivity] @transient def getsortedactivitylist(){ collections.sort(this.caseactivitylist) return this.caseactivitylist } } class caseactivity implements comparable { /** * activity id */ integer activityid...

multithreading - Writing a game loop for an ncurses game? -

i writing game ncurses , having trouble game loop. have read these 2 pages - this one , , this one several others linked via so, , can understand them (or @ least, can understand talking about, if not how solution works). problem have ncurses, sprites move 1 character step @ time, there no interpolation or integration, sprite.x=sprite.x+1 . tried using pthread , nanosleep , bad guy sprites move nicely player movement sluggish , unresponsive/unreactive. tried using 2 threads , having key input on 1 , game loop on thread key thread didn't @ all. so,how write smooth game loop ncurses? the main problem key presses (not key releases) can detected running in vt100 style terminal emulator (as ncurses does). little akward games. either player has press keys repeatedly move (or wait until key autorepeats if keybord driver configured so). or can make game player presses key once begin move , presses key again (or key perhaps) stop (like in old sierra adventure games). you...

version control - Xcode 5 with JGit repository -

Image
how can use xcode jgit repository instead of git repository? checkout dialog offers types “git” , “subversion”. if try open jgit repository traditional git type, error message says “fatal: unable find remote helper“. xcode doesn't directly support repo stored on s3 (it's unique jgit). that said, should able access repo there using combination of fuse os x , s3fs . need install fuse (which allows use of filesystems userland) , s3fs (to mount s3 bucket) , mount bucket containing repo somewhere on local filesystem. once that's done, you'll able reference using local filesystem mountpoint.

ruby - Image_tag in rails -

i've written this: <div id="table_01"> <div id="saveonshirts-website-homepage-01"> <image_tag("saveonshirts_website_homepage_01.png")> </div> <div id="saveonshirts-website-homepage-02"> <image_tag("saveonshirts_website_homepage_02.png")> </div> <div id="saveonshirts-website-homepage-03"> <image_tag("saveonshirts_website_homepage_03.png")> </div> images in images folder under assets folder. however, images still not showing in localhost. thoughts? thanks in advance! elton i'm assuming using erb , if need using erb scriptlet tags <%= ... %> example: <%= image_tag("saveonshirts_website_homepage_01.png") %> reference documentation: layouts , rendering in rails .

How to creating function with given code in C++? -

giving function creatcustomer() create customer. prototype: customer*creatcustomer(const string&name, const string&id, const string&pin) and given code below.the structure done myself. the question how create function using given code , prototype. #include <iostream> #include <iomanip> #include <string> using namespace std; struct customer { string customername; string userid; string pin; }; int main() { customer* mary = createcustomer("mary jones", "235718", "5074"); customer* john = createcustomer("john smith", "375864", "3251"); } first of in case don't need function, can do: customer mary { "mary jones", "235718", "5074" }; customer john { "john smith", "375864", "3251" }; but if need to, should use constructor: struct customer { std::string customername; std::string userid; std::string pin;...