Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Java Thread [moved] #149

Closed
lvca opened this issue Dec 10, 2012 · 0 comments
Closed

Support Java Thread [moved] #149

lvca opened this issue Dec 10, 2012 · 0 comments

Comments

@lvca
Copy link
Member

lvca commented Dec 10, 2012

This is Issue 149 moved from a Google Code project.
Added by 2010-11-18T11:58:43.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.
Closed (Done).

Original labels: Type-Defect, Priority-Medium

Original description

Hi all.
I don't find any documentation about support concurrent programming Java . 
May I can write code with use concurrent programming Java?
For example:

package com.action;

import com.model.Task;
import com.orientechnologies.orient.core.db.object.ODatabaseObjectTx;

public class TaskThread implements Runnable {
    private ODatabaseObjectTx db;
    private String parentId;

    public TaskThread(ODatabaseObjectTx db, String parentId) {
        this.db = db;
        this.parentId = parentId;
    }

    public void run() {
        createTask(parentId);
    }

    private void createTask(String parentId) {
        int currentId = TestThread.getCurrentId();
        Task task = new Task(String.valueOf(currentId), "task_"+currentId, parentId);
        System.out.println(Thread.currentThread() + " : id: " + task.getId() + "\tname: " + task.getName() + "\tparent: " + task.getParent());
        db.save(task);
    }
}


package com.action;

import com.orientechnologies.orient.core.db.object.ODatabaseObjectTx;

public class TestThread {
    private static int currectId = 0;
     private final static String URL = "local:/home/pitbull/projects/ThreadOriendDB/store/db1/trackstudio40";

    public static synchronized int getCurrentId() {
        return ++currectId;
    }

    public static void main(String[] args) {
        ODatabaseObjectTx db = new ODatabaseObjectTx(URL).open("admin", "admin");
        for (int i=0;i!=1000000;++i) {
            new Thread(new TaskThread(db, "1")).start();
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant