Daily Archives

Articles indexed Tuesday July 2 2013

Page 7/19 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • How to adjust Skype webcam resolution

    - by Felix Elnan
    I have finally gotten my webcam (philips spc 300nc) working in Skype, and i thought i was all set. But the resolution is to low (176x144) so it zoomz in on the side of my face. I downloaded guvcview and set the resolution to 352x288 and it showed perfectly, until i tried to start the webcam in Skype, beacause there it stil was in 176x144. I cant really figure out why. I preload skype with v4l2convert.so and the webcam works great in both Cheese, and guvcview.

    Read the article

  • Not recognized as operating system on startup

    - by mastabruce
    I am new to Ubuntu and just decided to install it in (on my new lenovo thinkpad) in addition to my windows 7 operating system. Now, whenever I reboot the computer, it only runs window 7. I went (in windows) to Control Pannel ? System ? Advanced Settings ? Startup and Ubuntu is not even listed as a choice for operating system. I tried installing ubuntu again, but now it wants to partition the already partitioned windows folder. I can't figure out how to get Ubuntu, which seems to be installed, to run. I saw on another question here that I could be able to edit my mrb settings using EasyBCD but I can not figure out how to choose ubuntu as an operating system. My disk is already partitioned (seen from the attempted second install) so I'm pretty sure it is on the disk. Basically, how can I get ubuntu to run when I can't choose it as an operating system? Thank you for your help.

    Read the article

  • Redirecting non existing post to homepage; is that good for SEO?

    - by BlackEagle
    I am checking my website out on Google Webmasters and I am seeing an astonishing 5000 links that could not be found by Google's Crawlers. That's normal, because my website is built in a manner that users can drop their own things, which also lead to 404 pages. Not a problem at all if I can find a workaround of course... So my question is: what if I made a function or a mod rewrite that will check if the link exists (a post for example) and if not, it will redirect it to the home page. Is this good for SEO? Will Google see this as 'link found'? How do I have to look at this problem?

    Read the article

  • 2 Google Tag Manager containers = double triggers?

    - by fred
    I have a Joomla website with existing analytics done by a GTM tag and I need to add another image tag (1x1 pixel) from a separate GTM container. I set the event name for the additional GTM container to a different name from from the existing GTM container (default 'gtm.js') so that the new tag only fires under the specified event. The new container tested out fine in a blank HTML page, but when it is put in the website, it ends up firing twice. I know that because Firebug showed 2 1x1 pixels being loaded and I mark each request with a randomly-generated UID to distinguish them on the server side. I suspect this being caused by having multiple GTM container tags but want to check whether anyone has run into this problem before? As of now, I could not verify nor fix the double counting problem.

    Read the article

  • how to fix bad seo after being hacked

    - by mkprogramming
    About a year ago my wordpress website was hacked & some company decided to go nuts and actually do some "SEO" on the various links it created. Some of the pages would show up on google as "payday cash advance" instead of "portfolio". The issue has been resolved, but now as I've been doing GOOD seo, I've noticed (when checking backlinks) that there are TONS of links still on the internet (mostly broken sites now) that have links to my website with titles like: "get a loan today" and so on. Is there a way to remove these links ? Can I tell google to ignore them ? Help !

    Read the article

  • How do I avoid spam domains pointing to my site or IP

    - by Amol Ghotankar
    I came across an issue where I saw some xyz.com is pointing to mydomain.com. How do I avoid spam domains pointing to my domain? I read some posts about setting my virtual hosts and such, but nothing specific about how to avoid it in the first place. I searched on Google but most answers are for HTTP servers and there are no exact answers for Tomcat 7. I am not using Apache or IIS, but Tomcat directly.

    Read the article

  • Create bullet physics rigid body along the vertices of a blender model

    - by Krishnabhadra
    I am working on my first 3D game, for iphone, and I am using Blender to create models, Cocos3D game engine and Bullet for physics simulation. I am trying to learn the use of physics engine. What I have done I have created a small model in blender which contains a Cube (default blender cube) at the origin and a UVSphere hovering exactly on top of this cube (without touching the cube) I saved the file to get MyModel.blend. Then I used File -> Export -> PVRGeoPOD (.pod/.h/.cpp) in Blender to export the model to .pod format to use along with Cocos3D. In the coding side, I added necessary bullet files to my Cocos3D template project in XCode. I am also using a bullet objective C wrapper. -(void) initializeScene { _physicsWorld = [[CC3PhysicsWorld alloc] init]; [_physicsWorld setGravity:0 y:-9.8 z:0]; /*Setup camera, lamp etc.*/ .......... ........... /*Add models created in blender to scene*/ [self addContentFromPODFile: @"MyModel.pod"]; /*Create OpenGL ES buffers*/ [self createGLBuffers]; /*get models*/ CC3MeshNode* cubeNode = (CC3MeshNode*)[self getNodeNamed:@"Cube"]; CC3MeshNode* sphereNode = (CC3MeshNode*)[self getNodeNamed:@"Sphere"]; /*Those boring grey colors..*/ [cubeNode setColor:ccc3(255, 255, 0)]; [sphereNode setColor:ccc3(255, 0, 0)]; float *cVertexData = (float*)((CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertices; int cVertexCount = (CC3VertexArrayMesh*)cubeNode.mesh).vertexLocations.vertexCount; btTriangleMesh* cTriangleMesh = new btTriangleMesh(); // for (int i = 0; i < cVertexCount * 3; i+=3) { // printf("\n%f", cVertexData[i]); // printf("\n%f", cVertexData[i+1]); // printf("\n%f", cVertexData[i+2]); // } /*Trying to create a triangle mesh that curresponds the cube in 3D space.*/ int offset = 0; for (int i = 0; i < (cVertexCount / 3); i++){ unsigned int index1 = offset; unsigned int index2 = offset+6; unsigned int index3 = offset+12; cTriangleMesh->addTriangle( btVector3(cVertexData[index1], cVertexData[index1+1], cVertexData[index1+2] ), btVector3(cVertexData[index2], cVertexData[index2+1], cVertexData[index2+2] ), btVector3(cVertexData[index3], cVertexData[index3+1], cVertexData[index3+2] )); offset += 18; } [self releaseRedundantData]; /*Create a collision shape from triangle mesh*/ btBvhTriangleMeshShape* cTriMeshShape = new btBvhTriangleMeshShape(cTriangleMesh,true); btCollisionShape *sphereShape = new btSphereShape(1); /*Create physics objects*/ gTriMeshObject = [_physicsWorld createPhysicsObjectTrimesh:cubeNode shape:cTriMeshShape mass:0 restitution:1.0 position:cubeNode.location]; sphereObject = [_physicsWorld createPhysicsObject:sphereNode shape:sphereShape mass:1 restitution:0.1 position:sphereNode.location]; sphereObject.rigidBody->setDamping(0.1,0.8); } When I run the sphere and cube shows up fine. I expect the sphere object to fall directly on top of the cube, since I have given it a mass of 1 and the physics world gravity is given as -9.8 in y direction. But What is happening the spere rotates around cube three or times and then just jumps out of the scene. Then I know I have some basic misunderstanding about the whole process. So my question is, how can I create a physics collision shape which corresponds to the shape of a particular mesh model. I may need complex shapes than cube and sphere, but before going into them I want to understand the concepts.

    Read the article

  • Jump and run HTML5 Game Framework

    - by user1818924
    We're developing a jump and run game with HTML5 and JavaScript and have to build an own game framework for this. Here we have some difficulties and would like to ask you for some advice: we have a "Stage" object, which represents the root of our game and is a global div-wrapper. The stage can contain multiple "Scenes", which are also div-elements. We would implement a Scene for the playing task, for pause, etc. and switch between them. Each scene can therefore contain multiple "Layers", representing a canvas. These Layer contain "ObjectEntities", which represent images or other shapes like rectangles, etc. Each Objectentity has its own temporaryCanvas, to be able to draw images for one entity, whereas another contains a rectangle. We set an activeScene in our Stage, so when the game is played, just the active scene is drawn. Calling activeScene.draw(), calls all sublayers to draw, which draw their entities (calling drawImage(entity.canvas)). But is this some kind of good practive? Having multiple canvas to draw? Each gameloop every layer-context is cleared and drawn again. E.g. we just have a still Background-Layer, … wouldn't it be more useful to draw this once and not to clear it everytime and redraw it? Or should we use a global canvas for example in the Stage and just use this canvas to draw? But we thought this would be to expensive... Other question: Do you have any advice how we could dive into implementing an own framework? Most stuff we find online relies on existing frameworks or they just implement their game without building a framework.

    Read the article

  • Multiplayer mobile games and coping with high latency

    - by liortal
    I'm currently researching regarding a design for an online (realtime) mobile multiplayer game. As such, i'm taking into consideration that latencies (lag) is going to be high (perhaps higher than PC/consoles). I'd like to know if there are ways to overcome this or minimize the issues of high latency? The model i'll be using is peer-to-peer (using Photon cloud to broadcast messages to all other players). How do i deal with a scenario where a message about a local object's state at time t will only get to other players at *t + HUGE_LAG* ?

    Read the article

  • How to set orthgraphic matrix for a 2d camera with zooming?

    - by MahanGM
    I'm using ID3DXSprite to draw my sprites and haven't set any kind of camera projection matrix. How to setup an orthographic projection matrix for camera in DirectX which it would be able to support zoom functionality? D3DXMATRIX orthographicMatrix; D3DXMATRIX identityMatrix; D3DXMatrixOrthoLH(&orthographicMatrix, nScreenWidth, nScreenHeight, 0.0f, 1.0f); D3DXMatrixIdentity(&identityMatrix); device->SetTransform(D3DTS_PROJECTION, &orthographicMatrix); device->SetTransform(D3DTS_WORLD, &identityMatrix); device->SetTransform(D3DTS_VIEW, &identityMatrix); This code is for initial setup. Then, for zooming I multiply zoom factor in nScreenWidth and nScreenHeight.

    Read the article

  • Compiling a Monogame Game into a single .exe

    - by user27483
    Is it possible to compile a monogame game into a single .exe? I know if you go in the debug or release bin, there is in fact a .exe your game, except you move this .exe's file location or try to run in on another computer it crashes. I am also aware of the one-click application except this seems like a really messy way of redistributing a monogame game. How come when you build your game, the exe for it wont work anywhere but that file location and that computer. I am also aware that the computer probably needs the XNA framework downloaded to play the monogame game, so in short is it possible to redistribute a monogame game by creating a single .exe and assume that person who is using it doesnt have XNA or monogame installed?

    Read the article

  • Could someone explain why my world reconstructed from depth position is incorrect?

    - by yuumei
    I am attempting to reconstruct the world position in the fragment shader from a depth texture. I pass in the 8 frustum points in world space and interpolate them across fragments and then interpolate from near to far by the depth: highp float depth = (2.0 * CameraPlanes.x) / (CameraPlanes.y + CameraPlanes.x - texture( depthTexture, textureCoord ).x * (CameraPlanes.y - CameraPlanes.x)); // Reconstruct the world position from the linear depth highp vec3 world = mix( nearWorldPos, farWorldPos, depth ); CameraPlanes.x is the near plane CameraPlanes.y is the far. Assuming that my frustum positions are correct, and my depth looks correct, why is my world position wrong? (My depth texture is of format GL_DEPTH_COMPONENT32F if that matters) Thanks! :D Update: Screenshot of world position http://imgur.com/sSlHd So you can see it looks nearly correct. However as the camera moves, the colours (positions) change, which they shouldnt. I can get this to work, if I do the following: Write this into the depth attachment in the previous pass: gl_FragDepth = gl_FragCoord.z / gl_FragCoord.w / CameraPlanes.y; and then read the depth texture like so: depth = texture( depthTexture, textureCoord ).x However this will kill the hardware z buffer optimizations.

    Read the article

  • htaccess Redirect - First Segment to PHP File, Second Segment as Parameter

    - by Steve
    My htaccess redirect knowledge is somewhat weak, so I was hoping to get some help here. I currently have the following redirect, which works well: # remove trailing slash RewriteRule ^(.*)/$ /$1 [L,R=301] # redirect to clean URL RewriteCond /%{REQUEST_FILENAME}.php -f RewriteRule ^([a-zA-Z0-9_-\s]+)$ /$1.php This takes a URL like www.mysite.com/about to www.mysite.com/about.php Now I would like to keep this behavior, but add parameters (if applicable), as such: www.mysite.com/about = www.mysite.com/about.php www.mysite.com/gallery/1 = www.mysite.com/gallery.php?id=1 If possible, I might like to expand this system to 2 or more parameters, as such: www.mysite.com/gallery/1/2 = www.mysite.com/gallery.php?id=1&section=2 So the pattern would be: First URL segment redirects to a PHP file (Optionally) the second segment gets added as the id parameter (Optionally) the third segment gets added as the section parameter

    Read the article

  • UIActionSheet With PickerView not showing up in iPad

    - by user717452
    I am using the following code to add an actionsheet with a picker view on it to my app. From the iPhone, it displays perfectly, but when viewing on iPad (Universal app), it shows a very small pickerview with none of the other buttons right on the center of the page. UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Select Chapter" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Select" otherButtonTitles:nil]; // Add the picker UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0,185,0,0)]; pickerView.delegate = self; pickerView.showsSelectionIndicator = YES; // note this is default to NO [menu addSubview:pickerView]; [menu showFromTabBar:self.tabBarController.tabBar]; [menu setBounds:CGRectMake(0,0,320, 700)]; [pickerView release]; [menu release];

    Read the article

  • Getting parameter sent via html form and saving in my db

    - by Wesley
    I have error in my code i don't know to solve it please help me: My Servlet: package br.com.cad.servlet; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import br.com.cad.dao.Cadastro; import br.com.cad.basica.Contato; public class AddDados extends HttpServlet{ protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { PrintWriter out = response.getWriter(); String nome = request.getParameter("nome"); String sobrenome = request.getParameter("sobrenome"); String rg = request.getParameter("rg"); String cpf = request.getParameter("cpf"); String sexo = request.getParameter("sexo"); StringBuilder finalDate = new StringBuilder("DataNascimento1") .append("/"+request.getParameter("DataNascimento??2")) .append("/"+request.getParameter("DataNascimento3")); try { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); finalDate.toString(); } catch(ParseException e) { out.println("Erro de conversão da data"); return; } Contato contato = new Contato(); contato.setNome(nome); contato.setSobrenome(sobrenome); contato.setRg(rg); contato.setCpf(cpf); contato.setSexo(sexo); if ("Masculino".equals(contato.getSexo())) { contato.setSexo("M"); } else { contato.setSexo("F"); } contato.setDataNascimento1(dataNascimento1); //error here ????? contato.setDataNascimento2(dataNascimento2); //error here ????? contato.setDataNascimento3(dataNascimento3); //error here ????? Cadastro dao = new Cadastro(); dao.adiciona(contato); out.println("<html>"); out.println("<body>"); out.println("Contato " + contato.getNome() + " adicionado com sucesso"); out.println("</body>"); out.println("</html>"); } } My object dao package br.com.cad.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Date; import br.com.cad.dao.ConnectDb; import br.com.cad.basica.Contato; public class Cadastro { private Connection connection; public Cadastro() { this.connection = new ConnectDb().getConnection(); } public void adiciona(Contato contato) { String sql = "INSERT INTO dados_cadastro(pf_nome, pf_ultimonome, pf_rg, pf_cpf, pf_sexo,pf_dt_nasc) VALUES(?,?,?,?,?,?,?,?)"; try { PreparedStatement stmt = connection.prepareStatement(sql); stmt.setString(1, contato.getNome()); stmt.setString(2, contato.getSobrenome()); stmt.setString(3, contato.getRg()); stmt.setString(4, contato.getCpf()); stmt.setString(5, contato.getSexo()); stmt.setDate(6, new Date( contato.getDataNascimento1().getTimeInMillis()) ); // i think there are error here i don't know to solve it ????? stmt.execute(); stmt.close(); System.out.println("Cadastro realizado com sucesso!."); } catch(SQLException sqlException) { throw new RuntimeException(sqlException); } } } My class cadastro package br.com.cad.basica; import java.util.Calendar; public class Contato { private Long id; private String nome; private String sobrenome; private String email; private String endereco; private Calendar dataNascimento1; private Calendar dataNascimento2; private Calendar dataNascimento3; private String rg; private String cpf; private String sexo; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNome() { return nome; } public void setNome(String nome) { this.nome = nome; } ...getters and setters I need to saving data in my mysql db, but i have some doubt about this code main how to get parameter send form html combobox( 1 for day, 2 for month, 3 for year of birth) i concatened with StringBuilder finalDate ... so i have some problem in my code please help me!!!

    Read the article

  • C# - Bug in Code Logic

    - by Matthew
    I have some code which keeps track of the number of times a button has been clicked. As a matter of fact, when the page first loads, a counter is set to 0. On every postback, the counter is incremented by 1. I have only one button on the page. The main idea behind this is to allow the user to enter some details 4 times. If he enters invalid details for 4 times, he is redirected to an error page. Otherwise, he is redirected to a confirmation page. This is my code: if (!this.IsPostBack) { Session["Count"] = 0; } else { if (Session["Count"] == null) { Session.Abandon(); Response.Redirect("CheckOutErrorPage.htm"); } else { int count = (int)Session["Count"]; if (count == 3) { Session.Abandon(); Response.Redirect("CheckOutFailure.aspx"); } else { count++; Session["Count"] = count; } } } Everything works as it should except that if the user enter invalid details for 3 times and then he enters VALID details on the 4th time, the user is redirected to the Error Page (because he has tried 4 times) instead of the confirmation page. How can I solve this please?

    Read the article

  • plot matrix missing points in different color using gnuplot

    - by kitt
    I have a file 'matrix.dat': 1 2 3 4 5 5 - 3 4 5 - 4 5 B - 1 B 2 B 3 - 3 2 - 3 I want to plot numbers using palette, '-' using white color and 'B' using black color. In gnuplot, I use this palette (blue - cyan - green - orange - red): set palette model HSV functions 0.666*(1-gray), 1, 1 And set '-' as missing data: set datafile missing "-" plot 'matrix.dat' matrix with image Now I can only plot numbers and '-' in correct colors.

    Read the article

  • Doctrine2 Mutliple DBs without Symfony2?

    - by ehime
    Hey guys I know that using the Doctrinebundle in Symfony2 it is possible to instantiate multiple DB connections under Doctrine... $connectionFactory = $this->container->get('doctrine.dbal.connection_factory'); $connection = $connectionFactory->createConnection(array( 'driver' => 'pdo_mysql', 'user' => 'foo_user', 'password' => 'foo_pass', 'host' => 'foo_host', 'dbname' => 'foo_db', )); I'm curious if this is the case if you are using PURELY Doctrine though?, I've set up Doctrine via Composer like so... { "config": { "vendor-dir": "lib/" }, "require": { "doctrine/orm": "2.3.4", "doctrine/dbal": "2.3.4" } } And have been looking for my ConnectionFactory class but am not seeing it anywhere? Am I required to use Symfony2 to do this? Thanks!

    Read the article

  • Approaches for cross server content sharing?

    - by Anonymity
    I've currently been tasked with finding a best solution to serving up content on our new site from another one of our other sites. Several approaches suggested to me, that I've looked into include using SharePoint's Lists Web Service to grab the list through javascript - which results in XSS and is not an option. Another suggestion was to build a server side custom web service and use SharePoint Request Forms to get the information - this is something I've only very briefly looked at. It's been suggested that I try permitting the requesting site in the HTTP headers of the serving site since I have access to both. This ultimately resulted in a semi-working solution that had major security holes. (I had to include username/password in the request to appease AD Authentication). This was done by allowing Access-Control-Allow-Origin: * The most direct approach I could think of was to simply build in the webpart in our new environment to have the authors manually update this content the same as they would on the other site. Are any one of the suggestions here more valid than another? Which would be the best approach? Are there other suggestions I may be overlooking? I'm also not sure if WebCrawling or Content Scrapping really holds water here...

    Read the article

  • Foreign Keys Duplicated in DataGridView

    - by John Doe
    I created a Windows Forms Application to which I added a DataGridView and LINQ to SQL Classes from one of my databases. I can successfully bind one of my database's tables to my DataGridView: var dataSource = from c in _db.NetworkedEquipments select c; dataGridView1.DataSource = dataSource; However, the foreign keys get duplicated, that is, the columns appear twice. How can I prevent this?

    Read the article

  • Test if Java trusts an SSL certificate

    - by Eric R. Rath
    My java web application uses the standard mail libraries to establish an IMAPS connection to a mail server under my control. The mail server used a valid SSL cert issued by a CA. When the cert expired, I renewed it from the same CA, and put the cert into use. But my web application wouldn't trust the new cert. We had never explicitly trusted the old cert, or managed any trust stores. I talked with someone from the CA, and we tracked it down to a difference in the intermediate certs between the old and new cert. The old one used multiple intermediates, including one tied to a root that must've been trusted by default by our version of Java. The new cert used only one intermediate cert, and it was tied to a root missing from our Java version's default trusted cert store. When we renew this cert again in the future, is there an easy way, given a new crt and intermediate crt file, test if Java will consider that cert valid? I didn't see anything in keytool that looked promising. A code solution is okay, but I'd prefer one based on the Java command-line tools.

    Read the article

  • PHP: Echo function output in function-line, not line of function call

    - by Brill
    I have a problem with my self-coded template system. The content is inserted by Include(). Now I need to add a meta redirect to one page. I know, meta redirect is not the safest way, but I need it because of it's delay possibility. Now i'm looking for a way to influence the wrapping page (template) by the wrapped page (content). So I thought a function can do this job. <?php function test($testvar){ echo $testvar;} ?> <hr /> <?php test("testtext"); ?> Of course the text echos in the line of the function call, not in the function line. Is there a way to make the function echo in the line of the function itself? In this case above the horizontal rule, not below? Of course every other best pratice for this "template problem" ist welcome! THX

    Read the article

  • Create a binary indicator matrix in R

    - by Brian Vanover
    I have a list of data indicating attendance to conferences like this: Event Participant ConferenceA John ConferenceA Joe ConferenceA Mary ConferenceB John ConferenceB Ted ConferenceC Jessica I would like to create a binary indicator attendance matrix of the following format: Event John Joe Mary Ted Jessica ConferenceA 1 1 1 0 0 ConferenceB 1 0 0 1 0 ConferenceC 0 0 0 0 1 Is there a way to do this in R? Sorry for the poor formatting.

    Read the article

  • How to download Google Cloud Messaging (GCM) from Google Code?

    - by Dennis
    I'm trying to learn how to use GCM and I want download the simple app. I'm following the instructions here: http://developer.android.com/google/gcm/server.html. Using App Engine for Java To set up the server using a standard App Engine for Java: Get the files from the open source site, as described above. I entered the link - https://code.google.com/p/gcm/ but there is no download there, and I don't have Git (and I don't know how to use it..). Can someone please explain how to download it or give me a link or something? Thank you in advance!

    Read the article

  • Multi-threading does not work correctly using std::thread (C++ 11)

    - by user1364743
    I coded a small c++ program to try to understand how multi-threading works using std::thread. Here's the step of my program execution : Initialization of a 5x5 matrix of integers with a unique value '42' contained in the class 'Toto' (initialized in the main). I print the initialized 5x5 matrix. Declaration of std::vector of 5 threads. I attach all threads respectively with their task (threadTask method). Each thread will manipulate a std::vector<int> instance. I join all threads. I print the new state of my 5x5 matrix. Here's the output : 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 It should be : 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 0 0 0 0 0 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4 Here's the code sample : #include <iostream> #include <vector> #include <thread> class Toto { public: /* ** Initialize a 5x5 matrix with the 42 value. */ void initData(void) { for (int y = 0; y < 5; y++) { std::vector<int> vec; for (int x = 0; x < 5; x++) { vec.push_back(42); } this->m_data.push_back(vec); } } /* ** Display the whole matrix. */ void printData(void) const { for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { printf("%d ", this->m_data[y][x]); } printf("\n"); } printf("\n"); } /* ** Function attached to the thread (thread task). ** Replace the original '42' value by another one. */ void threadTask(std::vector<int> &list, int value) { for (int x = 0; x < 5; x++) { list[x] = value; } } /* ** Return the m_data instance propertie. */ std::vector<std::vector<int> > &getData(void) { return (this->m_data); } private: std::vector<std::vector<int> > m_data; }; int main(void) { Toto toto; toto.initData(); toto.printData(); //Display the original 5x5 matrix (first display). std::vector<std::thread> threadList(5); //Initialization of vector of 5 threads. for (int i = 0; i < 5; i++) { //Threads initializationss std::vector<int> vec = toto.getData()[i]; //Get each sub-vectors. threadList.at(i) = std::thread(&Toto::threadTask, toto, vec, i); //Each thread will be attached to a specific vector. } for (int j = 0; j < 5; j++) { threadList.at(j).join(); } toto.printData(); //Second display. getchar(); return (0); } However, in the method threadTask, if I print the variable list[x], the output is correct. I think I can't print the correct data in the main because the printData() call is in the main thread and the display in the threadTask function is correct because the method is executed in its own thread (not the main one). It's strange, it means that all threads created in a parent processes can't modified the data in this parent processes ? I think I forget something in my code. I'm really lost. Does anyone can help me, please ? Thank a lot in advance for your help.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >