小编Mr.*_*ool的帖子

如何永久增加java堆内存?

我有java堆内存的一个问题.我在java中开发了一个客户端服务器应用程序,它作为Windows服务运行,需要超过512MB的内存.我有2GB的RAM,但是当我运行我的应用程序时,它会引发异常

内存不足错误:java堆空间

但我已经在java控制面板中设置了堆大小(最大512MB),我仍然得到相同的错误.我无法通过命令行设置堆大小,因为我的应用程序作为Windows服务运行,所以如何增加默认堆大小?

java heap jvm heap-memory heap-dump

21
推荐指数
2
解决办法
13万
查看次数

C++:eclipse CDT中的外部库

现在我使用eclipse CDT作为我的C/C++应用程序,但是当我链接我的外部库时出现问题,它无法在运行时正确加载,即使我把库文件放在源文件附近,我给了库路径,它的名称正确.

项目目录:

  1. 包括(.h文件)
  2. 来源(.cpp.文件..)
  3. LIB(libbozorth3.a,LSFMatcher.a)

我希望链接静态库与我的应用程序我遵循以下步骤:

  1. project-> properties-> general-> path和symbols-> include目录路径和库(bozorth3.a,LSFMatcher.a),并添加库路径.
  2. 我也在链接器部分添加了相同的库

当我构建程序时显示错误找不到-lbozorth3.a无法找到-lLSFMatcher.a

所以我需要正确的步骤将外部库添加到c/c ++应用程序.

c++ eclipse linux eclipse-cdt

7
推荐指数
1
解决办法
1万
查看次数

如何通过另一个线程停止线程?

我在Java中遇到了一些线程,我有三个线程 - thread1,thread2和thread3.当它开始时,它们正在做一些任务,我想通过thread1停止这两个线程.我把thread1用于sleep(500),然后我停止两个线程,但两个线程的进程仍在运行.你知道怎么做吗?

java multithreading

7
推荐指数
2
解决办法
2万
查看次数

如何在java中的某个时间启动进程?

我有一个应用程序从用户获取开始和结束时间并启动特定进程(开始时间)运行到(结束时间),对于示例我使用TimerTask实用程序,以防它只从当前时间开始进程和运行到(结束时间)我无法设置开始时间如何在java中共同设置用户时间(开始时间)和系统时间

//my sample  program
import java.sql.Date;
import java.util.Timer;
import java.util.TimerTask;

public class Main {
  public static void main(String[] argv) throws Exception {

     int numberOfMillisecondsInTheFuture=1000;

//    start time= dynamically set by user
//    end time =dynamically set by user


    Date timeToRun = new Date(System.currentTimeMillis() + numberOfMillisecondsInTheFuture);//here is the problem.
    Timer timer = new Timer();

    timer.schedule(new TimerTask() {
      public void run() {

      //System.out.println("doing");
      //doing some task not related to this question
      }
    }, timeToRun);
  }
Run Code Online (Sandbox Code Playgroud)

java timer scheduled-tasks timertask

5
推荐指数
0
解决办法
4988
查看次数

Linux 守护进程启动

我在linux(Redhat Server Edition 5.1)上编写了一项服务。它是由 shell script 启动的,如果我启动我的应用程序,我手动启动我的服务,现在我想在启动时启动我的服务,这意味着我将我的服务放在我的守护进程 init.d 文件夹中,而不是在启动时调用,有人知道如何在 Linux 上启动时启动守护进程吗?

这是我的样本,但不起作用

#!/bin/sh
#
# myservice     This shell script takes care of starting and stopping
#               the <myservice>
#

# Source function library
. /etc/rc.d/init.d/functions


# Do preliminary checks here, if any
#### START of preliminary checks #########


##### END of preliminary checks #######


# Handle manual control parameters like start, stop, status, restart, etc.

case "$1" in
  start)
    # Start daemons.

    echo -n $"Starting <myservice> daemon: "
    echo
    daemon …
Run Code Online (Sandbox Code Playgroud)

linux redhat daemon linux-kernel

5
推荐指数
1
解决办法
1万
查看次数

如何在Android中构建没有JNI的共享库?

我开发了一个Android应用程序,它需要是一个共享库。我已经在Linux(使用gcc)中制作了相同的库,所以我想在Android(ARM处理器)中编译相同的共享库。但是 NDK 只支持 JNI。现在我想构建一个没有直接 JNI 交互的单独共享库。我有很多 C 文件和头文件,所以我无法为所有内容编写 JNI。我想为 ARM 处理器构建我的库。我怎样才能做到这一点?

my stuture is
  ----->JNI
     ---->myfile.c(jni c code)
      ----->android.mk(here i call my two shared lib)

       folder1
             --->include
             ----src
             ---->lib(here i will get my shared lib)
       folder 2
            ----->include
            ----->src
            ----->lib(here i will get my 2nd shared lib)
Run Code Online (Sandbox Code Playgroud)

这里我想单独构建我的共享库,然后我会调用它。是否可以在 Android 中构建没有 JNI 的 shred lib?

java-native-interface android arm android-ndk eclipse-adt

5
推荐指数
2
解决办法
4813
查看次数

如何将列表分配给另一个列表?

我有一个问题处理列表,我有三个类命名为UserInf,用户数据,userProcess,我创建使用UserInf类一个通用的列表,我需要到该列表设置为其他列表,它是在课堂userprocess,这是我的示例代码*

public class UserInf 
{
    private List<Data> pData;

    private String userId;

public void setData(List<Data> pData)
    {
        this.pData=pData;// Need to assign the fpData
    }
    public List<Data> getData()
    {
        return this.pData;
    }

    public void setUserId(String userId)
    {
        this.userId = userId;
    }
    public String getUserId()
    {
        return userId;
    }
Run Code Online (Sandbox Code Playgroud)

在我的其他类userdata我使用userInf创建列表,添加添加这样的值

List<UserInf> userInformation=new ArrayList<UserInf>();
UserInf userInfo=new UserInf();
userInfo.setUserId(userid);
  userInfo.setData(pdata);
userInformation.add(userInfo);//up to this working fine


}
Run Code Online (Sandbox Code Playgroud)

在我的其他类userprocees中,我想将userInformation列表分配给另一个列表我为userInf类创建了对象ang获取属性并分配给我的新列表

List<UserInf> userProcessList=new ArrayList<UserInf>();
UserInf userProcess=new UserInf();
userProcess.getData();
userProcess.getUserId();
userProcessList.add(userProcess);//problem is here
Run Code Online (Sandbox Code Playgroud)

但这不是如何将列表分配给java中的另一个列表

java collections list arraylist

4
推荐指数
1
解决办法
2万
查看次数

如何使用recv()在C++套接字中重用超过65000个字节

我正在使用C++在Linux中开发客户端服务器应用程序(TCP).我想同时发送多个65,000字节.在TCP中,最大数据包大小65,535仅为字节.

如何在不丢失的情况下发送整个字节?

以下是我在服务器端的代码.

//Receive the message from client socket
if((iByteCount = recv(GetSocketId(), buffer, MAXRECV, MSG_WAITALL)) > 0) 
{
     printf("\n Received bytes %d\n", iByteCount);

     SetReceivedMessage(buffer);
     return LS_RESULT_OK;
}
Run Code Online (Sandbox Code Playgroud)

如果我使用MSG_WAITALL它需要很长时间来接收字节,那么如何设置标志以便在时间上接收超过100万字节.

编辑:MTU大小为1500字节,但如果为65,535,则为TCP数据包大小的绝对限制.

c++ sockets linux tcp serversocket

3
推荐指数
1
解决办法
9325
查看次数

如何从java中的链表中删除对象?

我的代码有一个问题,我做了一个示例程序来显示链接列表中的emp详细信息,现在我尝试删除特定条目时的问题意味着它不起作用,我希望我的代码中有一些错误你能建议怎么做吗?

import java.util.*;

class EmpDedup {
    int record;
    String fprint;
    int fid;

    EmpDedup(int record, String fprint, int fid) {
        this.record = record;
        this.fprint = fprint;
        this.fid = fid;
    }

    public int getRecord() {
        return record;
    }

    public String getFprint() {
        return fprint;
    }

    public int getFid() {
        return fid;
    }

    public static void main(String[] args) {
        int count = 0;
        LinkedList<EmpDedup> list = new LinkedList<EmpDedup>();
        list.add(new EmpDedup(101, "entry1", 20));
        list.add(new EmpDedup(102, "entry2", 30));
        list.add(new EmpDedup(103, "entry3", 40));
        list.add(new EmpDedup(104, "entry4", …
Run Code Online (Sandbox Code Playgroud)

java linked-list data-structures singly-linked-list

3
推荐指数
3
解决办法
2万
查看次数

如何在特定时间安排任务?

我有一个java调度程序的问题,我的实际需要是我必须在特定时间开始我的进程,我会在某个时间停止,我可以在特定时间开始我的进程但我不能在某个时间停止我的进程,如何指定进程在调度程序中运行多长时间(这里我不会放入),任何人都有建议.

import java.util.Timer;
import java.util.TimerTask;
import java.text.SimpleDateFormat;
import java.util.*;
public class Timer
{
    public static void main(String[] args) throws Exception
    {

                  Date timeToRun = new Date(System.currentTimeMillis());
                  System.out.println(timeToRun);
                  Timer timer1 = new Timer();
                  timer1.schedule(new TimerTask() 
                   { 
                     public void run() 
                               {

                        //here i call another method
                        }

                    } }, timeToRun);//her i specify my start time


            }
}
Run Code Online (Sandbox Code Playgroud)

java scheduling timer scheduled-tasks

3
推荐指数
1
解决办法
2万
查看次数