C******e 发帖数: 1850 | 1 I have a mutlithread question need your help. I want to create a thread to
do some task in the background, but the problem is both this background
thread and the main() function will use a common global variable, say gdata.
For example, the background thread changes the value of gdata, and the main
() function uses gdata for some calculation. So how do I make sure the main(
) function uses the up-to-date value of gdata? In other words, how do I
synchronize the value of gdata between the backgrou |
|
y****e 发帖数: 1012 | 2 在一个机器上写一个jar,用eclipse配置了native library~但是在另外一个机器上却跑
不了……
/usr/lib/jvm/jdk1.7.0/bin/java -Djava.library.path=./lib -Dfile.encoding=UT
F-8 -classpath ./target/classes:./lib/gdata-core-1.0.jar:./lib/gdata-client-
1.0.jar:./lib/gdata-maps-2.0.jar:./lib/gdata-media-1.0.jar:./lib/lpsolve55j.
jar:./target/DCPlacement-jar-with-dependencies.jar:/usr/share/java/log4j-1.2
.jar DatacenterLocator -g 10,10 -l 4000 -s heuristic
报错:
Exception in thread "Thread-3" Exception in thread "Thread-0" Exception in t
h... 阅读全帖 |
|
|
|
|
|
a****l 发帖数: 8211 | 7 it seems you only have two threads, one main, one background. Then it's very
simple, no need for "advanced" things like mutex. Just add one global
boolean, when background has a new value and boolean is 0, write the value,
set boolean to 1; the main thread keeps checking boolean, if 1, read value,
finish work, then set boolean to 0.
gdata.
main
main(
) |
|
M**u 发帖数: 10158 | 8 java/javascript
有个gdata project
finance page? |
|
s*****n 发帖数: 2174 | 9 > library(gdata)
> trim(" abc ")
[1] "abc"
不过这个本质上也是调用sub. |
|
s*****n 发帖数: 2174 | 10 MM还是要继续磨练啊, 这样写R程序可不太成.
这件事情, 在 library(gdata) 里面有个unmatrix()函数可以很容易就实现.
即使不用现成函数, 自己去写, 也完全不需要循环就可以搞定. |
|
S********a 发帖数: 359 | 11 > library(gdata)
> mydata=read.xls("c:\Study\NJ\pre\copy.xls")
给出下面信息
Error in findPerl(verbose = verbose) :
perl executable not found. Use perl= argument to specify the correct path.
Error in file.exists(tfn) : invalid 'file' argument
怎么回事呢? |
|
l*********s 发帖数: 5409 | 12 gdata package requires perl |
|
J****n 发帖数: 54 | 13 用 gdata package 暂时搞定了。
But you are right, CSV is much better. |
|
w****u 发帖数: 16 | 14 果然是有leading space ... R trim function (gdata package) does the trick.
thanks.... |
|
s*****d 发帖数: 2667 | 15 read.table 读不进来,用了RODBC package
> library(RODBC)
> channel <- odbcConnectExcel("D:datadata.xls")
> mydata <- sqlFetch(channel, "Sheet1")
> odbcClose(channel)
> mydata
显示
[1] "HY000 -5038 [Microsoft][ODBC Excel Driver] The connection for viewing
your linked Microsoft Excel worksheet was lost."
[2] "[RODBC] ERROR: Could not SQLExecDirect 'SELECT * FROM [Sheet1$]'"
用gdata好象更麻烦
同样的数据 txt file 就能读进来
怎么解决, 请教一下达人。谢谢 |
|
a***d 发帖数: 336 | 16 csv has only one tab, xls can have many...
I used read.xls from gdata. sometimes it works sometimes doesn't..:( |
|