Control mesh vertecies position

My test code for creating dynamic mesh from lines. I dont know how to control vertecies from other no point meshes.

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

/**
 *
 * @author Admin
 */

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Spatial;
import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Format;
import com.jme3.scene.VertexBuffer.Usage;
import com.jme3.texture.Texture;
import com.jme3.util.BufferUtils;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;



public class LineMesh extends SimpleApplication
{
   public static class SimpleSprit
   {
      public Vector3f position;
      public float size = 1f;
      public ColorRGBA color ;
      public float startX = 1f;
      public float startY = 1f;
      public float endX = 0f;
      public float endY = 0f;
   }
   
   Mesh[] mesh ; 
   private int spritesNum = 1000;
   private int meshNum=10;
    LineMesh.SimpleSprit[][] sprites = new LineMesh.SimpleSprit[meshNum][spritesNum];
   Texture tex ;
   Material mat;
  FloatBuffer positions = BufferUtils.createFloatBuffer(3000);// fix the buffer

   public static void main(String[] args)
   {
      LineMesh app = new LineMesh();
      app.start();
   }

   @Override
   public void simpleInitApp()
   { mesh= new Mesh[meshNum];
      getViewPort().setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));
      getFlyByCamera().setMoveSpeed(50);
      for (int i=0;i<meshNum;i++){
      mesh[i] = createSpriteMesh(sprites[i]);}
            float min = 0;
      float max = 3;
      for (int j=0;j<meshNum;j++){
          for(int i=0; i< spritesNum-1; i=i+2)
      {
         sprites[j][i] = new LineMesh.SimpleSprit();
         sprites[j][i+1] = new LineMesh.SimpleSprit();
         sprites[j][i].position = new Vector3f(i+j,0,0);
         sprites[j][i+1].position = new Vector3f(i+j,2,0);
         sprites[j][i].color = ColorRGBA.White; sprites[j][i+1].color = ColorRGBA.White;
      }}
       
      for (int i=0;i<meshNum;i++){
      updateParticleData(mesh[i],sprites[i]);
      
      Geometry geom = new Geometry("", mesh[i]);
     
      mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    
      mat.setColor("Color", new ColorRGBA(0.118f, 0.118f, 0.545f, 0.25f));
      
      tex = assetManager.loadTexture("2d/npc/npc0.png");
      tex.setMinFilter(Texture.MinFilter.NearestNoMipMaps);
      tex.setMagFilter(Texture.MagFilter.Nearest);
      geom.setMaterial(mat); geom.setCullHint(Spatial.CullHint.Dynamic);
     
      THread thread = new THread(); thread.setDaemon(true);
      thread.start();
      rootNode.attachChild(geom);
      }
      rootNode.setCullHint(Spatial.CullHint.Dynamic);
   }

   int a = 0;
   @Override
   public void simpleUpdate(float tpf)
   {
     super.simpleUpdate(tpf);
    
     for (int j=0;j<meshNum;j++){
       
    
      updateParticleData(mesh[j], sprites[j]);}
   }
   
   public void updateParticleData(Mesh mesh, LineMesh.SimpleSprit[] particles)
   {
      VertexBuffer pvb = mesh.getBuffer(VertexBuffer.Type.Position);
    //  FloatBuffer positions = (FloatBuffer) pvb.getData();
    //  FloatBuffer positions = BufferUtils.createFloatBuffer(3000);//?Solve bug - jme reads after buffer limit
      
      VertexBuffer cvb = mesh.getBuffer(VertexBuffer.Type.Color);
      ByteBuffer colors = (ByteBuffer) cvb.getData();

      VertexBuffer svb = mesh.getBuffer(VertexBuffer.Type.Size);
      FloatBuffer sizes = (FloatBuffer) svb.getData();

      VertexBuffer tvb = mesh.getBuffer(VertexBuffer.Type.TexCoord);
      FloatBuffer texcoords = (FloatBuffer) tvb.getData();

      // update data in vertex buffers
      positions.rewind();
      colors.rewind();
      sizes.rewind();
      texcoords.rewind();
      for (int i = 0; i < spritesNum; i++)
      {
         LineMesh.SimpleSprit p = particles[i];
         positions.put(p.position.x).put(p.position.y).put(p.position.z);
         colors.putInt(p.color.asIntABGR());
         sizes.put(p.size);
         texcoords.put(p.startX).put(p.startY).put(p.endX).put(p.endY);
      }
      positions.flip();
      colors.flip();
      sizes.flip();
      texcoords.flip();

      // force renderer to re-send data to GPU
      pvb.updateData(positions);
      cvb.updateData(colors);
      svb.updateData(sizes);
      tvb.updateData(texcoords);
      mesh.updateBound();
      mesh.updateCounts();
   }

   public static void initBuffer(Mesh mesh, VertexBuffer.Type type, Buffer pb, Usage usage, int components, Format format, boolean normalise)
   {
      VertexBuffer pvb = new VertexBuffer(type);
      pvb.setupData(usage, components, format, pb);
      if (normalise) pvb.setNormalized(true);

      VertexBuffer buf = mesh.getBuffer(type);
      if (buf != null)
      {
         buf.updateData(pb);
      }
      else
      {
         mesh.setBuffer(pvb);
      }
   }

   public Mesh createSpriteMesh(LineMesh.SimpleSprit[] sprites)
   {
      Mesh spriteMesh = new Mesh();
      int numParticles = sprites.length;
      spriteMesh.setMode(Mesh.Mode.Lines);
       spriteMesh.setLineWidth(2);
      initBuffer(spriteMesh, VertexBuffer.Type.Position, BufferUtils.createFloatBuffer(numParticles*3), Usage.Stream, 3, Format.Float       , false );
      initBuffer(spriteMesh, VertexBuffer.Type.Color   , BufferUtils.createByteBuffer(numParticles*4) , Usage.Stream, 4, Format.UnsignedByte, true  );
      initBuffer(spriteMesh, VertexBuffer.Type.Size    , BufferUtils.createFloatBuffer(numParticles)  , Usage.Stream, 1, Format.Float       , false );
      initBuffer(spriteMesh, VertexBuffer.Type.TexCoord, BufferUtils.createFloatBuffer(numParticles*4), Usage.Stream, 4, Format.Float       , false );

      return spriteMesh;
   }
   public class THread extends Thread{
   public THread(){}
   public void run()
   {  while (System.currentTimeMillis()>0)
       try
      {      for (int j=0;j<meshNum;j++){
          for (int i=0; i<spritesNum-1;i=i+2)
     {
      sprites[j][ i].position.y=(float)Math.random()*2;
     }
        Thread.sleep(1); 
      }
         //  sleep(1000);
      }
     catch (InterruptedException exception) { }
}}}

I noticed, that in example “Particles3d” Examples for use OpenCL in Java with LWGL
used another technique to control vertex position.

It impress that there dont call vertex update the buffer in mesh. This can improve some performance without calling buffer update?

I did not understand how this technique work, and tutorial http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_meshes
does not disclose this theme fully.

And further my code based on TestJmeReadsAfterBufferLimit.java
https://code.google.com/p/petomancer/downloads/list
that can throw BufferOverflowException when put in nio.Buffer, but I probably resolve this by use fixed size of buffer.